新手!!!急求进!!!
帮忙看下程序哪里错了,谢谢!!!主要是银行用户的存款问题.看了好久不知道为什么错了,请帮帮看看!我用的tc++3.0编译器.#include<iostream.h>
#include<string.h>
const int k=2;
int x,y;
class xxx
{
private:
int acount;//用户的帐号
int password;//用户的密码
char name[10];//用户的名字
int left_money;//用户的余款
public:
void set(int num,int mima,char x[10],int money);//对类的私有成员进行赋值
int check(int x,int y);//核对帐号和密码
void score(int add);//存放大小为add的钱
void take(int disadd);//取走大小为disadd的钱
void left_mon();//查看余款
};
void xxx::set(int num,int mima,char x[10],int money)
{
acount=num;
password=mima;
strcpy(name,x);
left_money=money;
}
int xxx::check(int x,int y)
{
if(acount==x&&password==y)
return 1;
else
return 0;
}
void xxx::score(int add)
{
if(check(x,y)==1)
{
cout<<"before:"<<left_money<<"yuan"<<endl;
left_money+=add;
cout<<"now:"<<left_money<<"yuan"<<endl;
}
else
cout<<"NO!"<<endl;
}
void take(int disadd)
{
if(check(x,y)==1&&disadd<=left_money)
{
cout<<"before:"<<left_money<<"yuan"<<endl;
left_money-=disadd;
cout<<"nou:"<<left_money<<"yuan"<<endl;
}
else
cout<<"NO!"<<endl;
}
void left_mon()
{
if(check(x,y)==1)
cout<<"the money left is:"<<left_money<<endl;
else
cout<<"NO!"<<endl;
}
int main()
{
xxx os[k];
int i,num,mima,money;
char name[10];
for(i=0;i<k;i++)
{
cout<<"acount=";
cin>>num;
cout<<"password=";
cin>>mima;
cout<<"name=";
cin>>name;
cout<<"total_money=";
cin>>money;
os[i].set(num,mima,name,money);
}
for(i=0;i<k;i++)
{
int add,disadd;
cout<<"x=";
cin>>x;
cout<<"y=";
cin>>y;
cout<<"add=";
cin>>add;
os[i].score(add);
cout<<"disadd=";
cin>>disadd;
os[i].take(disadd);
os[i].left_mon();
}
return 0;
}