main.cpp

来自「一个模拟银行账户管理的软件」· C++ 代码 · 共 75 行

CPP
75
字号
#include"a.h"

struct Bank_Struct{
	Bank_Account temp;
	Bank_Struct * next;
};

int Select(){
	int n=1;
	cout<<"请选择要进行的操作:"<<endl;
	cout<<"1 注册新帐户"<<endl;
	cout<<"2 登录帐户"<<endl;
	cout<<"0 退出"<<endl;
	cin>>n;
	return n;
}

Bank_Struct* In_Account(ifstream &in,Bank_Struct* p){
	in.open("Bank_Account.txt",ios::app);
	if(!in){
		cout<<"打开失败!";
	}
	while(!in.eof()){
		Bank_Struct* b=new(Bank_Struct);
		p->next=b;
		p=p->next;
		p->temp.In_Account(in);
		p->next=NULL;
	}
	return p;
}

int Check_Password(Bank_Struct* p){
	char Account[20];
	char Password[20];
	cout<<"请输入帐号:";
	cin>>Account;
	cout<<"请输入密码:";
	cin>>Password;
	while(p->next!=NULL){
		if(strcmp(p->temp.Return_Account(),Account)==0){
			if(strcmp(p->temp.Return_Password(),Password)==0){
				cout<<"登录成功!";
			}
		}
	}
	return 1;
}

int main(){
	Bank_Struct* head=new(Bank_Struct);
	head->next=NULL;
	Bank_Struct* p;
	ifstream in;
	p=In_Account(in,head);
	int n;
	n=Select();
	while(n!=0){
		switch(n){
		case 1:
			Bank_Struct* a=new(Bank_Struct);
			if(a->temp.New_Bank_Account()==1) cout<<"帐户创建成功,您的帐号为:"<<a->temp.Return_Account()<<endl;
			p->next=a;
			p=p->next;
			p->next=NULL;
			break;
		//case 2:
			//if(Check_Password(head)==1) cout<<"ok";
			//break;
		}
		n=Select();
	}
	in.close();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?