#include"iostream.h"
#include"iomanip.h"
#include"string.h"
#include"stdlib.h"
#include"fstream.h"
#define N 1000000000
class bank
{
protected:
struct node
{
int account;
int mima;
float money;
}fn[N];
public:
bank()
{ int i;
fstream file("bank.txt",ios::in);
while(1)
{ for(i=0;i<=N;i++)
{
file.read((char *)&fn[i].account,sizeof(fn[i].account));
file.read((char *)&fn[i].mima,sizeof(fn[i].mima));
file.read((char *)&fn[i].money,sizeof(fn[i].money));
if(!file) break;
}
}
file.close();
}
void newaccount()//新建帐户
{
int i,b,bb;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input the mima:"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
cout<<"Please input the startmoney:"<<endl;
cin>>c;
if(bb!=b) cout<<"The mima is error!"<<endl;
else{
fn[i++].account;
fn[i].mima=b;
fn[i].money=c;
}
}
}
void findaccount()///查找
{
int a,b,bb,i;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(b!=bb||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<setw(10)<<"account"<<setw(10)<<"leftmoney"<<endl;
cout<<setw(10)<<fn[i].account<<setw(10)<<fn[i].money<<endl;
}
}
}
}
void changmima()//修改密码
{
int a,b1,bb1,bb2,b2,i;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb1;
cout<<"Please input the mima again:"<<endl;
cin>>b1;
if(b1!=bb1||b1!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the newmima:"<<endl;
cin>>bb2;
cout<<"Please input the newmima again:"<<endl;
cin>>b2;
if(bb2!=b2) cout<<"The mima is error!"<<endl;
else fn[i].mima=b2;
}
}
}
}
void inmoney()//存款
{
int a,b,bb,i;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(bb!=b||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the inmoney:"<<endl;
cin>>c;
fn[i].money+=c;
}
}
}
}
void outmoney()//取款
{
int a,b,bb,i;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(bb!=b||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the outmoney:"<<endl;
cin>>c;
if(c>=fn[i].money) cout<<"Sorry! The money of account is little!"<<endl;
else fn[i].money-=c;
}
}
}
}
void zhuanmoney()//转帐
{
int a1,a2,b1,bb1,i;float c;
struct node fn_1[N];
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a1;
if(a1!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb1;
cout<<"Please input the mima again:"<<endl;
cin>>b1;
if(bb1!=b1||b1!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the other account:"<<endl;
cin>>a2;
if(a2!=fn_1[i].account) cout<<"the account is error!"<<endl;
else
{cout<<"Please input the outmoney"<<endl;
cin>>c;
if(c>=fn[i].money) cout<<"Sorry,the money is little!"<<endl;
else
{
fn[i].money-=c;
fn_1[i].money+=c;
}
}
}
}
}
}
void quit()
{char tomenu;
cout<<"请按'q'或'Q'返回"<<endl; //返回主菜单提示
do{
cin>>tomenu;
}while(!(tomenu=='q'||tomenu=='Q'));return ;
}
~bank()
{
fstream file("bank.txt",ios::out);
for(int i=0;i<=N;i++)
if(fn[i].account==0&&fn[i].mima==0&&fn[i].money==0)
{
file.write((char *)&fn[i].account,sizeof(fn[i].account));
file.write((char *)&fn[i].mima,sizeof(fn[i].mima));
file.write((char *)&fn[i].money,sizeof(fn[i].money));
}
file.close();
}
};
void main()
{
bank f1;
int select;
while(1)
{
cout<<setw(5)<<"********************************************************************"<<endl;
cout<<setw(15)<<"欢迎使用3_209银行帐户管理系统!"<<endl;
cout<<setw(15)<<"(版权归209用户所有,禁止非法盗用,否则我们很生气,后果很严重!)"<<endl;
cout<<setw(5)<<"********************************************************************"<<endl;
cout<<"创建新帐户请选:1"<<endl<<"查帐请选:2"<<endl<<"存款请选:3"<<endl<<"取款请选:4"<<endl<<"转帐请选:5"<<"修改密码请选: 6"<<endl<<"退出请选: 7"<<endl;
do
{
cin>>select;
}while(select==1||select==2||select==3||select==4||select==5||select==6||select==7);
switch(select)
{
case '1':
f1.newaccount();break;
case '2':
f1.findaccount();break;
case '3':
f1.inmoney();break;
case '4':
f1.outmoney();break;
case '5':
f1.zhuanmoney();break;
case '6':
f1.changmima();break;
case '7':
f1.quit();
}
}
}
#include"iostream.h"
#include"iomanip.h"
#include"string.h"
#include"stdlib.h"
#include"fstream.h"
#define N 1000000000
class bank
{
protected:
struct node
{
int account;
int mima;
float money;
}fn[N];
public:
bank()
{ int i;
fstream file("bank.txt",ios::in);
while(1)
{ for(i=0;i<=N;i++)
{
file.read((char *)&fn[i].account,sizeof(fn[i].account));
file.read((char *)&fn[i].mima,sizeof(fn[i].mima));
file.read((char *)&fn[i].money,sizeof(fn[i].money));
if(!file) break;
}
}
file.close();
}
void newaccount()//新建帐户
{
int i,b,bb;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input the mima:"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
cout<<"Please input the startmoney:"<<endl;
cin>>c;
if(bb!=b) cout<<"The mima is error!"<<endl;
else{
fn[i++].account;
fn[i].mima=b;
fn[i].money=c;
}
}
}
void findaccount()///查找
{
int a,b,bb,i;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(b!=bb||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<setw(10)<<"account"<<setw(10)<<"leftmoney"<<endl;
cout<<setw(10)<<fn[i].account<<setw(10)<<fn[i].money<<endl;
}
}
}
}
void changmima()//修改密码
{
int a,b1,bb1,bb2,b2,i;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb1;
cout<<"Please input the mima again:"<<endl;
cin>>b1;
if(b1!=bb1||b1!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the newmima:"<<endl;
cin>>bb2;
cout<<"Please input the newmima again:"<<endl;
cin>>b2;
if(bb2!=b2) cout<<"The mima is error!"<<endl;
else fn[i].mima=b2;
}
}
}
}
void inmoney()//存款
{
int a,b,bb,i;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(bb!=b||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the inmoney:"<<endl;
cin>>c;
fn[i].money+=c;
}
}
}
}
void outmoney()//取款
{
int a,b,bb,i;float c;
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a;
if(a!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima"<<endl;
cin>>bb;
cout<<"Please input the mima again:"<<endl;
cin>>b;
if(bb!=b||b!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the outmoney:"<<endl;
cin>>c;
if(c>=fn[i].money) cout<<"Sorry! The money of account is little!"<<endl;
else fn[i].money-=c;
}
}
}
}
void zhuanmoney()//转帐
{
int a1,a2,b1,bb1,i;float c;
struct node fn_1[N];
for(i=0;i<=N;i++)
{
cout<<"Please input your account:"<<endl;
cin>>a1;
if(a1!=fn[i].account) cout<<"The account is error!"<<endl;
else
{
cout<<"Please input the mima:"<<endl;
cin>>bb1;
cout<<"Please input the mima again:"<<endl;
cin>>b1;
if(bb1!=b1||b1!=fn[i].mima) cout<<"The mima is error!"<<endl;
else
{
cout<<"Please input the other account:"<<endl;
cin>>a2;
if(a2!=fn_1[i].account) cout<<"the account is error!"<<endl;
else
{cout<<"Please input the outmoney"<<endl;
cin>>c;
if(c>=fn[i].money) cout<<"Sorry,the money is little!"<<endl;
else
{
fn[i].money-=c;
fn_1[i].money+=c;
}
}
}
}
}
}
void quit()
{char tomenu;
cout<<"请按'q'或'Q'返回"<<endl; //返回主菜单提示
do{
cin>>tomenu;
}while(!(tomenu=='q'||tomenu=='Q'));return ;
}
~bank()
{
fstream file("bank.txt",ios::out);
for(int i=0;i<=N;i++)
if(fn[i].account==0&&fn[i].mima==0&&fn[i].money==0)
{
file.write((char *)&fn[i].account,sizeof(fn[i].account));
file.write((char *)&fn[i].mima,sizeof(fn[i].mima));
file.write((char *)&fn[i].money,sizeof(fn[i].money));
}
file.close();
}
};
void main()
{
bank f1;
int select;
while(1)
{
cout<<setw(5)<<"********************************************************************"<<endl;
cout<<setw(15)<<"欢迎使用3_209银行帐户管理系统!"<<endl;
cout<<setw(15)<<"(版权归209用户所有,禁止非法盗用,否则我们很生气,后果很严重!)"<<endl;
cout<<setw(5)<<"********************************************************************"<<endl;
cout<<"创建新帐户请选:1"<<endl<<"查帐请选:2"<<endl<<"存款请选:3"<<endl<<"取款请选:4"<<endl<<"转帐请选:5"<<"修改密码请选: 6"<<endl<<"退出请选: 7"<<endl;
do
{
cin>>select;
}while(select==1||select==2||select==3||select==4||select==5||select==6||select==7);
switch(select)
{
case '1':
f1.newaccount();break;
case '2':
f1.findaccount();break;
case '3':
f1.inmoney();break;
case '4':
f1.outmoney();break;
case '5':
f1.zhuanmoney();break;
case '6':
f1.changmima();break;
case '7':
f1.quit();
}
}
}
出什么问题了..求助挖