| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 648 人关注过本帖
标题:各位大虾帮我看看这个问题
只看楼主 加入收藏
林仲
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2004-12-26
收藏
 问题点数:0 回复次数:0 
各位大虾帮我看看这个问题
请各位大哥看看这个c++的问题

我想有c++编一个普通的“银行管理系统”,并且把它写进文件,但是出现一些问题,或者思路也有问题,希望大虾们帮我看看并改正,谢谢~!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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();
}

}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
希望大哥们耐心讲解下

[此贴子已经被作者于2005-6-23 11:17:47编辑过]


搜索更多相关主题的帖子: account include 银行管理 public money 
2005-06-23 10:51
快速回复:各位大虾帮我看看这个问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017426 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved