编程语言
首页 > 编程语言> > 【C++】银行存取款管理系统

【C++】银行存取款管理系统

作者:互联网

一、 定义结构体

#include"stdio.h"
#include"iostream"
#include"string.h"
#include<windows.h>

using namespace std;
int num=0;
struct Login{//登录结构体,有用户名和密码 
	char username[10];
	char password[10];
}lg[100];
struct Customerinfo{
	char idcard[10];
	char cuname[20];
	char cupwd[10];
	char cuaddr[30];
	char phone[11];
	float total;
}customer[100];
struct record{
	char idcard[10];
	char date[12];
	char category[8];
	float number;
	char Handler[20];
}dwrecord[1000];

二、实现系统登录功能

int SystemLogin(char *uname,char *pword){//系统登录功能 
	FILE *fp;
	int i;
	if((fp=fopen("login.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return 0;
	}
	for(i=0;!feof(fp);i++){
		fscanf(fp,"%s%s",&lg[i].username,&lg[i].password);
		if((strcmp(lg[i].username,uname)==0)&&(strcmp(lg[i].password,pword)==0))
			return 1;
	}
	fclose(fp);
	return 0;
}

 三、主界面设计

int display(){//主界面 
	int m;
	printf("--欢迎使用银行存取款系统,请选择你要执行的操作--\n");
	printf("------------------------------------------------\n");
	printf("--   0.退出系统                  1.录入信息   --\n"); 
	printf("--   2.存储                      3.取款       --\n");
	printf("--   4.存款查询                  5.取款查询   --\n");
	printf("--   6.显示信息                  7.删除信息   --\n");
	printf("--   8.修改信息                  9.存取款统计 --\n");
	printf("--   10.客户存取款排序                        --\n");
	printf("------------------------------------------------\n");
	printf("请输入您的选择(0-10)\n");
	scanf("%d",&m);
	while(m>10||m<0){
		printf("你选择的编号有误请重新输入\n");
		scanf("%d",&m);
	}
	return m;
}

 四、录入信息功能的实现

void insertcustomer(){//录入客户的账号信息 
	FILE *fp;
	int i,j,total;
	char c;
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
	}
	for(j=0;!feof(fp);j++){
		total++;
		fscanf(fp,"%s%s%s%s%s%f",&customer[j].idcard,&customer[j].cuname,&customer[j].cupwd,&customer[j].cuaddr,&customer[j].phone,&customer[j].total);
	}
	fp=fopen("Customerinfo.txt","a");
	for(i=0;i<100;i++){
		printf("请输入%d个人的信息",i+1);
		printf("编号:");
		scanf("%s",&customer[i].idcard);
		printf("客户姓名:");
		scanf("%s",&customer[i].cuname);
		printf("支取密码:");
		scanf("%s",&customer[i].cupwd);
		printf("客户地址:");
		scanf("%s",&customer[i].cuaddr);
		printf("客户电话:");
		scanf("%s",&customer[i].phone);
		printf("账户总金额:");
		scanf("%f",&customer[i].total);
		if((i+1)%1==0){
			getchar();
			printf("是否继续录入客户信息(y|Y)");
			scanf("%c",&c);
			if(c!='Y'&&c!='y')
				break;
		}
	}
	if(total>0)
		fprintf(fp,"\n","");
	for(int j=0;j<=i;j++){
		if(j<i-1)
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	fclose(fp);
	printf("数据保存成功,按回车键继续...");
	getchar();
	getchar();
}

五、存款功能的实现 

void deposit(){//存款操作 
	system("cls");
	printf("正在进行存款操作!");
	int i,j,flag=0,n=0,total=0,m=0;
	float k;
	FILE *fp,*ap;
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("请输入客户编号:\n");
	scanf("%s",&dwrecord[m].idcard);
	for(i=0;!feof(fp);i++){//读取用户信息,判断所要进行存款操作的账户是否存在 
		fscanf(fp,"%s%s%s%s%s%f",&customer[j].idcard,&customer[j].cuname,&customer[j].cupwd,&customer[j].cuaddr,&customer[j].phone,&customer[j].total);
		if(strcmp(customer[i].idcard,dwrecord[m].idcard)==0){
			flag=1;
			n=i;
		}
	}
	if(flag){//找到相应的账户,进行存款操作 
		ap=fopen("record.txt","a");
		printf("请输入你的存款金额:\n");
		scanf("%f",&k);
		customer[n].total=customer[n].total+k;//用原来的余额+存入的金额等于现有金额
		strcpy(dwrecord[n].idcard,customer[n].idcard);
		printf("请输入日期:\n");
		scanf("%s",dwrecord[n].date);
		strcpy(dwrecord[n].category,"存款");
		dwrecord[n].number=k;
		printf("请输入经办人:\n");
		scanf("%s",&dwrecord[n].Handler);
		fprintf(ap,"\n%s\t%s\t%s\t%0.2f\t%s",dwrecord[n].idcard,dwrecord[n].date,dwrecord[n].category,k,dwrecord[n].Handler);
		fclose(ap); 
	}
	else{
		printf("查无此人!");
		fclose(fp);
		printf("按回车键继续...");
		getchar();
		getchar();
		return;
	}
	fclose(fp);
	fp=fopen("Customerinfo.txt","a");
	for(j=0;j<total;j++){
		if(j<=total-1)//最后一行不换行,不是最后一行要换行
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	fclose(fp);
	printf("数据保存成功,按回车键继续...");
	getchar();
	getchar();
}

六、取款功能的实现 

void fetch(){//取款操作 
	system("cls");
	printf("正在进行取款操作...\n");
	int i,j,flag=0,n=0,m=0;
	char pwd[10];
	float k;
	FILE *fp,*ap;
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("请输入客户编号\n");
	scanf("%s",&dwrecord[m].idcard);
	for(i=0;!feof(fp);i++){//读取客户信息文件,判断所要进行取款操作的账户是否存在
		fscanf(fp,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
		if(strcmp(customer[i].idcard,dwrecord[m].idcard)==0){
			flag=1;
			n=i;
		}
	}
	if(flag){//找到相应的账户,进行取款操作 
	L1:	printf("请输入密码:\n");
		scanf("%s",pwd);
		if(strcmp(customer[n].cupwd,pwd)==0){
			printf("请输入你的取款金额:\n");
			scanf("%f",&k);
			if(k>customer[n].total){
				printf("您的余额不足!\n");
				Sleep(1000);
			}
			else{
				ap=fopen("record.txt","a");
				customer[n].total=customer[n].total-k;//用原来的余额-取出的金额等于现有金额
				strcpy(dwrecord[n].idcard,customer[n].idcard);
				printf("请输入日期:\n");
				scanf("%s",dwrecord[n].date);
				strcpy(dwrecord[n].category,"取款");
				dwrecord[n].number=k;
				printf("请输入经办人:\n");
				scanf("%s",&dwrecord[n].Handler);
				fprintf(ap,"%s\t%s\t%s\t%0.2f\t%s\n",dwrecord[n].idcard,dwrecord[n].date,dwrecord[n].category,k,dwrecord[n].Handler);
				fclose(ap); 
			}
		}
		else{
			num++;
			if(num<3){
				printf("密码错误,请重新输入!\n");
				Sleep(2000);
				goto L1;
			}
			return;
		} 
	}
	else{
		printf("查无此人!");
		Sleep(2000);
		return;
	}
	fclose(fp);
	fp=fopen("Customerinfo.txt","w");
	for(j=0;j<=i-1;j++){
		if(j<i-1)//最后一行不换行,不是最后一行要换行 
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	fclose(fp);
	printf("取款成功,欢迎再次光临,按回车键继续...");
	getchar();
	getchar();
}

七、存款记录查询功能的实现 

void SearchDeposit(){//存款查询 
	char id[10],name[20];
	int i,k=0,flag=0;
	FILE *fp,*ap;
	if((fp=fopen("record.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	if((ap=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("查询存款信息,请输入查询方式(1 按账号查询/2 按姓名查询):");
	scanf("%d",&k);
	while(k<1||k>2){
		printf("你输入的功能有错,请重新输入你要的查询功能(1-2)");
		scanf("%d",&k);
	}
	if(k==1){
		printf("请输入客户编号:\n");
		scanf("%s",id);
		printf("编号\t日期\t类别\t存入金额\t经办人\n");
		for(i=0;feof(fp);i++){//读取存款记录文件,判断所要查询的账号的存款记录。 
			fscanf(fp,"%s%s%s%f%s",&dwrecord[i].idcard,&dwrecord[i].date,&dwrecord[i].category,&dwrecord[i].number,&dwrecord[i].Handler);
			if((strcmp(dwrecord[i].idcard,id)==0)&&(strcmp(dwrecord[i].category,"存款")==0)){
				printf("%s\t%s\t%s\t%0.2f\t\t%s\n",dwrecord[i].idcard,dwrecord[i].date,dwrecord[i].category,dwrecord[i].number,dwrecord[i].Handler);
				flag=1;
			}
		}
		if(!flag){
			printf("该账号不存在或没有存款记录!\n");
			fclose(fp);
			printf("按回车键继续...");
			getchar();
			getchar();
			return;
		}
	}
	if(k==2){
		printf("请输入客户姓名:\n");
		scanf("%s",name);
		printf("编号\t日期\t类别\t存入金额\t经办人\n");
		for(i=0;feof(ap);i++){//读取客户信息文件,根据客户姓名查找相应的账号,判断所要进行查询操作的账号是否存在。 
			fscanf(ap,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
			if((strcmp(customer[i].cuname,name)==0)){
				strcpy(id,customer[i].idcard);
				break;
			}
		}
		for(i=0;feof(fp);i++){//读取客户信息文件,根据客户姓名查找相应的账号,判断所要进行查询操作的账号是否存在。 
			fscanf(fp,"%s%s%s%f%s",&dwrecord[i].idcard,&dwrecord[i].date,&dwrecord[i].category,&dwrecord[i].number,&dwrecord[i].Handler);
			if((strcmp(dwrecord[i].idcard,id)==0)&&(strcmp(dwrecord[i].category,"存款")==0)){
				printf("%s\t%s\t%s\t%0.2f\t\t%s\n",dwrecord[i].idcard,dwrecord[i].date,dwrecord[i].category,dwrecord[i].number,dwrecord[i].Handler);
				flag=1;
			}
		}
		if(!flag){
			printf("该账号不存在或没有存款记录!\n");
			fclose(fp);
			printf("按回车键继续...");
			getchar();
			getchar();
			return;
		}
	}
	fclose(fp);
	fclose(ap);
	printf("按回车键继续...");
	getchar();
	getchar();
}

八、取款记录查询功能的实现 

void SearchFetch(){//取款查询 
	char id[10],name[20];
	int i,k=0,flag=0;
	FILE *fp,*ap;
	if((fp=fopen("record.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	if((ap=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("查询取款信息,请输入查询方式(1 按账号查询/2 按姓名查询):");
	scanf("%d",&k);
	while(k<1||k>2){
		printf("你输入的功能有错,请重新输入你要的查询功能(1-2)");
		scanf("%d",&k);
	}
	if(k==1){
		printf("请输入客户编号:\n");
		scanf("%s",id);
		printf("编号\t日期\t类别\t取出金额\t经办人\n");
		for(i=0;feof(fp);i++){//读取客户信息文件,判断所要进行取款查询操作的账户的取款记录 
			fscanf(fp,"%s%s%s%f%s",&dwrecord[i].idcard,&dwrecord[i].date,&dwrecord[i].category,&dwrecord[i].number,&dwrecord[i].Handler);
			if((strcmp(dwrecord[i].idcard,id)==0)&&(strcmp(dwrecord[i].category,"取款")==0)){
				printf("%s\t%s\t%s\t%0.2f\t\t%s\n",dwrecord[i].idcard,dwrecord[i].date,dwrecord[i].category,dwrecord[i].number,dwrecord[i].Handler);
				flag=1;
			}
		}
		if(!flag){
			printf("该账号不存在或没有取款记录!\n");
			fclose(fp);
			printf("按回车键继续...");
			getchar();
			getchar();
			return;
		}
	}
	if(k==2){
		printf("请输入客户姓名:\n");
		scanf("%s",name);
		printf("编号\t日期\t类别\t取出金额\t经办人\n");
		for(i=0;feof(ap);i++){//读取客户信息文件,根据客户姓名查找相应的账号,判断所要进行取款查询操作的账号是否存在。 
			fscanf(ap,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
			if((strcmp(customer[i].cuname,name)==0)){
				strcpy(id,customer[i].idcard);
				break;
			}
		}
		for(i=0;feof(fp);i++){//读取客户信息文件,根据客户姓名查找相应的账号,判断所要进行查询操作的账号是否存在。 
			fscanf(fp,"%s%s%s%f%s",&dwrecord[i].idcard,&dwrecord[i].date,&dwrecord[i].category,&dwrecord[i].number,&dwrecord[i].Handler);
			if((strcmp(dwrecord[i].idcard,id)==0)&&(strcmp(dwrecord[i].category,"取款")==0)){
				printf("%s\t%s\t%s\t%0.2f\t\t%s\n",dwrecord[i].idcard,dwrecord[i].date,dwrecord[i].category,dwrecord[i].number,dwrecord[i].Handler);
				flag=1;
			}
		}
		if(!flag){
			printf("该账号不存在或没有存款记录!\n");
			fclose(fp);
			printf("按回车键继续...");
			getchar();
			getchar();
			return;
		}
	}
	fclose(fp);
	fclose(ap);
	printf("按回车键继续...");
	getchar();
	getchar();
}

 九、删除信息功能的实现

void DeleteInfo(){
	FILE *fp;
	int i,j,k,flag=0,total=0;
	char id[10];
	if((fp=fopen("Customer.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("请输入你要删除信息的客户编号:");
	scanf("%s",id);
	for(i=0;!feof(fp);i++){
		total++;
		fscanf(fp,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
		if(strcmp(customer[i].idcard,id)==0){
			k=i;
			flag=1;
		}
	}
	if(!flag){
		printf("你输入的客户编号有误,请正确输入你要删除的客户!\n");
		fclose(fp);
		printf("按回车键继续...");
		getchar();
		getchar();
		return;
	}
	for(j=k;j<total;j++){
		strcpy(customer[j].idcard,customer[j+1].idcard);
		strcpy(customer[j].cuname,customer[j+1].cuname);
		strcpy(customer[j].cupwd,customer[j+1].cupwd);
		strcpy(customer[j].cuaddr,customer[j+1].cuaddr);
		strcpy(customer[j].phone,customer[j+1].phone);
		customer[j].total=customer[j+1].total;
	}
	fclose(fp);
	fp=fopen("Customer.txt","w");
	for(j=0;j<total-1;j++){
		if(j!=total-2)
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%0.2f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	printf("删除客户信息成功, 按回车键继续...!\n");
	fclose(fp);
	getchar();
	getchar();
}

十、显示信息功能的实现 

void ShowCuInfo(){
	int i;
	FILE *ap;
	if((ap=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("编号\t姓名\t客户密码\t客户地址\t客户电话\t金额\n");
	for(i=0;!feof(ap);i++){//读取客户信息文件,判断所要进行操作的账号是否存在
		fscanf(ap,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
		printf("%s\t%s\t%s\t\t%s\t\t%s\t%0.2f\n",customer[i].idcard,customer[i].cuname,customer[i].cupwd,customer[i].cuaddr,customer[i].phone,customer[i].total);
	}
	fclose(ap);
	printf("按回车键继续...");
	getchar();
	getchar();
}

十一、客户存取款信息排序功能的实现 

void SortCustomer(){
	FILE *ap;
	int i,j,n,k,flag=0,total=0;
	char id[10];
	if((ap=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	struct Customerinfo temp;
	printf("编号\t姓名\t客户密码\t客户地址\t客户电话\t金额\n");
	for(i=0;!feof(ap);i++){
		total++;
		fscanf(ap,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
	}
	for(n=0;n<total;n++){
		for(j=total-1;j>=n;j--){
			if(customer[j].total<customer[j+1].total){
				{
					strcpy(temp.idcard,customer[j].idcard);
					strcpy(temp.cuname,customer[j].cuname);
					strcpy(temp.cupwd,customer[j].cupwd);
					strcpy(temp.cuaddr,customer[j].cuaddr);
					strcpy(temp.phone,customer[j].phone);
					temp.total=customer[j].total;
				}
				{
					strcpy(customer[j].idcard,customer[j+1].idcard);
					strcpy(customer[j].cuname,customer[j+1].cuname);
					strcpy(customer[j].cupwd,customer[j+1].cupwd);
					strcpy(customer[j].cuaddr,customer[j+1].cuaddr);
					strcpy(customer[j].phone,customer[j+1].phone);
					customer[j].total=customer[j+1].total;
				}
				{
					strcpy(customer[j+1].idcard,temp.idcard);
					strcpy(customer[j+1].cuname,temp.cuname);
					strcpy(customer[j+1].cupwd,temp.cupwd);
					strcpy(customer[j+1].cuaddr,temp.cuaddr);
					strcpy(customer[j+1].phone,temp.phone);
					customer[j+1].total=temp.total;
				}
			}
		}
		for(i=0;i<total;i++){
			printf("%s\t%s\t%s\t%s\t%s\t%f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		}
	}
	fclose(ap);
	printf("按回车键继续...");
	getchar();
	getchar();
}

十二、修改信息功能的实现 

void UpdataInfo(){
	FILE *fp;
	int i,j,k,flag=0,total=0,n;
	char id[10],addr[30],phone[11],pwd[10];
	if((fp=fopen("Customerinfo.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	printf("请输入你要修改信息的客户编号:");
	scanf("%s",id);
	for(i=0;!feof(fp);i++){
		total++;
		fscanf(fp,"%s%s%s%s%s%f",&customer[i].idcard,&customer[i].cuname,&customer[i].cupwd,&customer[i].cuaddr,&customer[i].phone,&customer[i].total);
		if(strcmp(customer[i].idcard,id)==0){
			k=i;
			flag=1;
		}
	}
	if(!flag){
		printf("你输入的客户编号有误,请正确输入你要修改的客户!\n");
		fclose(fp);
		printf("按回车键继续...");
		getchar();
		getchar();
		return;
	}
	printf("请选择你要修改的信息:(1修改密码  2修改地址  3修改电话):\n");
	scanf("%d",&n);
	while(n<1||n>3){
		printf("你输入的功能有错,请重新输入你要的修改功能(1-2):");
		scanf("%d",&n);
	}
	switch(n){
		case 1:{
			printf("请输入旧密码:");
			scanf("%s",pwd);
			if(strcmp(customer[k].cupwd,pwd)==0){
				printf("请输入新密码:");
				scanf("%s",pwd);
				strcpy(customer[k].cupwd,pwd);
				printf("密码修改成功,按回车键继续...!\n");
				getchar();
				getchar();
			}
			else{
				printf("旧密码不正确,按回车键继续...!\n");
				getchar();
				getchar();
			}
			break;
		}
		case 2:{
			printf("请输入新地址:");
			scanf("%s",addr);
			strcpy(customer[k].cuaddr,addr);
			printf("地址修改成功,按回车键继续...!\n");
			getchar();
			getchar();
			break;
		}
		case 3:{
			printf("请输入新电话号码:");
			scanf("%s",phone);
			strcpy(customer[k].phone,phone);
			printf("电话修改成功,按回车键继续...!\n");
			getchar();
			getchar();
			break;
		}
	}
	fclose(fp);
	fp=fopen("Customerinfo.txt","w");
	for(j=0;j<total;j++){
		if(j<total-1)
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f\n",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
		else
			fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%f",customer[j].idcard,customer[j].cuname,customer[j].cupwd,customer[j].cuaddr,customer[j].phone,customer[j].total);
	}
	printf("修改客户信息成功,按回车键继续...!\n");
	fclose(fp);
	getchar();
}

十三、存取款统计功能的实现 

void Statistics(){
	FILE *fp;
	int i,j,flag[100],total=0;
	char id[10],cat[6];
	system("cls");
	printf("正在统计信息...\n");
	if((fp=fopen("record.txt","r"))==NULL){
		printf("文件打开失败!\n");
		return;
	}
	for(i=0;!feof(fp);i++){
		fscanf(fp,"%s%s%s%f%s",&dwrecord[i].idcard,&dwrecord[i].date,&dwrecord[i].category,&dwrecord[i].Handler);
		total++;
		flag[i]=0;
	}
	for(i=0;i<total;i++){
		if(flag[i]==0){
			strcpy(id,dwrecord[i].idcard);
			strcpy(cat,dwrecord[i].category);
			flag[i]=1;
			for(j=i+1;j<total;j++){
				if((strcmp(dwrecord[j].idcard,id)==0)&&(strcmp(dwrecord[j].category,cat)==0)){
					dwrecord[i].number=dwrecord[i].number+dwrecord[j].number;
					flag[j]=1;
				}
			}
			printf("账号为%s的客户共%s%0.2f元。",dwrecord[i].idcard,dwrecord[i].category,dwrecord[i].number);
			printf("\n---------------------------------------------------\n");
		}
	}
	fclose(fp);
	printf("按回车键继续...");
	getchar();
	getchar();
}

十四、主函数 

int main(int argc, char** argv) {//主函数 
	char un[10],pass[10];
	int k=0;
L:	printf("欢迎使用银行存取款系统,请输入用户名和密码登录系统!\n");
	printf("用户名:");
	scanf("%s",un);
	printf("密码:");
	scanf("%s",pass);
	if(SystemLogin(un,pass)==1){
		printf("用户名和密码正确,正在登录系统...\n");
		Sleep(2000);
		system("cls");
		k=display();
		while(k){
			switch(k){
				case 1:insertcustomer();break;
				case 2:deposit();		break;
				case 3:fetch();			break;
				case 4:SearchDeposit();	break;
				case 5:SearchFetch();	break;
				case 6:ShowCuInfo();	break;
				case 7:DeleteInfo();	break;
				case 8:UpdataInfo();	break;
				case 9:Statistics();	break;
				case 10:SortCustomer();	break;
			}
			system("cls");
			k=display();
		}
	}
	else{
		printf("用户名或密码错误,请重新输入!\n");
		Sleep(2000);
		system("cls");
		num++;
		if(num<3)
			goto L;
	}
}

标签:customer,fp,idcard,管理系统,存取款,C++,printf,dwrecord,s%
来源: https://blog.csdn.net/weixin_53158593/article/details/123101359