《银行管理系统.doc》由会员分享,可在线阅读,更多相关《银行管理系统.doc(26页珍藏版)》请在三一办公上搜索。
1、#includestdio.h#includestring.h#includeconio.h#includestdlib.h#includetime.h# define N 40#define M 15struct perchar mz20; char zh20;char mm20;char time_jl128;int money;int statue;memM,dat;struct jiluchar mz20;char zh20;long int money;char cunqu;char time_jl128;s;void main()void open();void cunk();vo
2、id quk();void delect();void change();void chaxun();void zhuanzh();void bu(); int i;FILE *fp;/struct per memM;/struct jilu sN;char hangguan=mrhang,hgmm=yh2009, hg20,hg120;bu1:printf(t*tn);printf(ttt欢迎登陆银行管理系统n);printf(n);printf(请输入管理员帐号:);scanf(%s,hg);printf(请输入登陆口令:);i=0;while(1)hg1i=getch();if(hg1i
3、=13)break;putchar(*);i+;hg1i=0;printf(n);if(strcmp(hangguan,hg)=0&strcmp(hgmm,hg1)=0)system(cls);printf(登陆成功!n); bu();elsesystem(cls);printf(输入有误,请重新登陆n);goto bu1; fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(cannot open!n);return;for(i=0;!feof(fp);i+)fread(&memi,sizeof(struct per),1,fp);fclose(fp);void
4、bu()int l; void open();void cunk();void quk();void delect();void change();void chaxun();void zhuanzh();printf(tt Welcome Tonn);printf(ttt1:申请账户请按1+Enter!n); printf(ttt2:存款操作请按2+Enter!n); printf(ttt3:取款操作请按3+Enter!n); printf(ttt4:销户操作请按4+Enter!n); printf(ttt5:修改密码请按5+Enter!n); printf(ttt6:如需查询请按6+Ent
5、er!n); printf(ttt7:转账请按7+Enter!n); printf(请选择:);doscanf(%d,&l); switch(l)case 1:system(cls);open();break; case 2:system(cls);cunk();break; case 3:system(cls);quk();break; case 4:system(cls);delect();break; case 5:system(cls);change();break; case 6:system(cls);chaxun();break; case 7:system(cls);zhuan
6、zh();break;default:printf(输入有误,请重新输入);while(l!=0);void open() FILE *fp,*fp1;int i,j; char mm_ok20;struct per temp; fp = fopen(d:帐目.txt,ab); printf(请输入您的名字:); scanf(%s,dat.mz);lp: fp1 = fopen(d:帐目.txt,rb); printf(输入您的帐号:); scanf(%s,dat.zh);while(fread(&temp,sizeof(temp),1,fp1)!=0) if (strcmp (dat.zh,
7、temp.zh)=0) printf(此帐号已经有人用了,请重新输入.n); fclose(fp1); goto lp; tp:printf(输入密码:);j=0; while(1)dat.mmj=getch();if(dat.mmj=13)break;putchar(*);j+;dat.mmj=0;printf(n); printf(确认密码:);i=0; while(1)mm_oki=getch();if(mm_oki=13)break;putchar(*);i+;mm_oki=0; if(strcmp(dat.mm,mm_ok) !=0) printf(确认密码不一样!请重新输入.n);
8、 goto tp; dat.money = 0; dat.statue=1; fwrite(&dat,sizeof(dat),1,fp); fclose(fp); printf(n操作时间:n);time_t now;now=time(NULL);printf(%sn,ctime(&now); printf(申请成功.n); printf(输入任何键返回菜单.n);getch();system(cls); bu();void cunk()FILE *fp,*fp2,*fp3;void bu();/struct per mem128; char zh20; char mm20;char time
9、_n128; int money,i,j,len; fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(还没有一个人申请帐号.n); printf(输入任何键返回菜单.n); getch();goto end; printf(请输入你的帐号:); scanf(%s,zh); printf(密码:); j=0; while(1)mmj=getch();if(mmj=13)break;putchar(*);j+;mmj=0;printf(n);for(i=0;!feof(fp);i+)fread(mem+i,sizeof(struct per),1,fp);len=i-
10、1;rewind(fp);i=0; while(!feof(fp) fread(mem+i,sizeof(struct per),1,fp); if(strcmp(zh,memi.zh)=0 & strcmp(mm,memi.mm)=0) printf(请输入你要存款的数额:); scanf(%d,&money); memi.money=memi.money + money; break; i+;if(feof(fp)!=0) printf(帐号不存在!n); printf(按任何键返回菜单.n); getch(); goto end;/*printf(%d,len);*/time_t now
11、;now=time(NULL);strcpy(time_n,ctime(&now);fp3=fopen(d:记录.txt,ab);strcpy(s.mz,memi.mz);strcpy(s.zh,memi.zh);strcpy(s.time_jl,time_n);s.money=money;s.cunqu=c;fwrite(&s,sizeof(struct jilu),1,fp3);fclose(fp3);fp2=fopen(d:帐目.txt,wb+);for(i=0;imemi.money)printf(对不起,您的余额不足!n);printf(按任何键返回菜单.n);getch();got
12、o end; memi.money=memi.money - money; break; i+;if(feof(fp)!=0) printf(帐号不存在!n); printf(按任何键返回菜单.n); getch(); goto end;/*printf(%d,len);*/time_t now;now=time(NULL);strcpy(time_n,ctime(&now);fp3=fopen(d:记录.txt,ab);strcpy(s.mz,memi.mz);strcpy(s.zh,memi.zh);strcpy(s.time_jl,time_n);s.money=money;s.cunq
13、u=q;fwrite(&s,sizeof(struct jilu),1,fp3);fclose(fp3);fp2=fopen(d:帐目.txt,wb+);for(i=0;ilen;i+)fwrite(mem+i,sizeof(struct per),1,fp2);fclose(fp2);fclose(fp);printf(n存款成功!n);printf(n操作时间:n);printf(%sn,time_n);printf(按任何键返回菜单.n);getch();system(cls);end:bu(); void delect() FILE *fp,*fp2;void bu();struct
14、per num128; char zh20; char mm20;char yn5,yn1=y; int i,j,len; fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(还没有一个人申请帐号.n); printf(输入任何键返回菜单.n); getch();goto end; printf(请输入你的帐号:); scanf(%s,zh); printf(密码:); j=0; while(1)mmj=getch();if(mmj=13)break;putchar(*);j+;mmj=0;printf(n);for(i=0;!feof(fp);i+)fread(n
15、um+i,sizeof(struct per),1,fp);len=i-1;/printf(%dn,len);rewind(fp);i=0; while(!feof(fp) fread(num+i,sizeof(struct per),1,fp); if(strcmp(zh,numi.zh)=0&strcmp(mm,numi.mm)=0)printf( n);printf( 是否注销此账户(y/n)-n);printf( n);printf(请选择是否销户:);scanf(%s,yn);if(strcmp(yn,yn1)=0)numi.statue=0;printf(right);goto x
16、h; elseprintf(您已取消注销此帐户n);printf(按任何键返回菜单.n);getch();goto end;i+;if(feof(fp)!=0) printf(帐号不存在!n); printf(按任何键返回菜单.n); getch(); goto end;xh:fp2=fopen(d:帐目.txt,wb+);for(i=0;ilen;i+)if(numi.statue!=0)fwrite(num+i,sizeof(struct per),1,fp2);fclose(fp2);fclose(fp);printf(操作成功!n);printf(n操作时间:n);time_t now
17、;now=time(NULL);printf(%sn,ctime(&now);printf(按任何键返回菜单.n);getch();system(cls);end:bu();void chaxun1()void chaxun();FILE *fp;int i,len,x,j,flag=0;char zh120,mm120;fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(cannot open!n);return;printf(请输入要查询的帐号:);scanf(%s,zh1);i=0;while(!feof(fp)fread(&memi,sizeof(struc
18、t per),1,fp);i+;len=i-1;for(i=0;ilen;i+)if(strcmp(memi.zh,zh1)=0)break; while(flag=0)printf(请输入你的密码:); j=0; while(1)mm1j=getch();if(mm1j=13)break;putchar(*);j+; mm1j=0;printf(n);if(strcmp(memi.mm,mm1)=0)flag=1;elseprintf(输入有误,请重新输入。n);if(flag=1)printf(你当前的帐户余额为:%ldn,memi.money);fclose(fp); printf(n操
19、作时间:n);time_t now;now=time(NULL);printf(%sn,ctime(&now);printf(输入任何键返回菜单.n);scanf(%d,&x);system(cls);chaxun();void chaxun2()void chaxun();FILE *fp;int i,len,x,j,flag=0;char zh120,mm120;fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(cannot open!n);return;printf(请输入要查询的帐号:);scanf(%s,zh1);i=0;while(!feof(fp)f
20、read(&memi,sizeof(struct per),1,fp);i+;len=i-1;for(i=0;ilen;i+)if(strcmp(memi.zh,zh1)=0)break; while(flag=0)printf(请输入你的密码:); j=0; while(1)mm1j=getch();if(mm1j=13)break;putchar(*);j+; mm1j=0;printf(n);if(strcmp(memi.mm,mm1)=0)flag=1;elseprintf(输入有误,请重新输入。n);if(flag=1)printf( 姓名 帐号 金额 密码n );printf(%-
21、10s%-10s%-10ld%-10sn,memi.mz,memi.zh,memi.money,memi.mm);fclose(fp); printf(n操作时间:n);time_t now;now=time(NULL);printf(%sn,ctime(&now); printf(输入任何键返回菜单.n);scanf(%d,&x);system(cls);chaxun();void chaxun3()void chaxun();FILE *fp1,*fp2;struct jilu sN;int i,j,len,len1,x,k,flag=0;char zh120,mm120;fp1=fope
22、n(d:帐目.txt,rb); fp2=fopen(d:记录.txt,rb);if(fp1=NULL)printf(cannot open 1!n);return;if(fp2=NULL)printf(cannot open 2!n);return;printf(请输入要查询的帐号:);scanf(%s,zh1);i=0;while(!feof(fp1)fread(&memi,sizeof(struct per),1,fp1);i+;len=i-1;for(i=0;ilen;i+)if(strcmp(memi.zh,zh1)=0)break;while(flag=0)printf(请输入你的密
23、码:); k=0; while(1)mm1k=getch();if(mm1k=13)break;putchar(*);k+; mm1k=0;printf(n);if(strcmp(memi.mm,mm1)=0)flag=1;elseprintf(输入有误,请重新输入。n); j=0; while(!feof(fp2) fread(&sj,sizeof(struct jilu),1,fp2); j+; len1=j-1; printf(账号 金额 类型 时间n); for(j=0;jlen1;j+) if(strcmp(sj.zh,zh1)=0) printf(%-10s%-10ld%-5c%s
24、n,sj.zh,sj.money,sj.cunqu,sj.time_jl);fclose(fp1);fclose(fp2); printf(输入任何键返回菜单.n);scanf(%d,&x);system(cls);chaxun();void chaxun()int i;void bu();printf(tt-查询界面-nn); printf(ttt1:余额查询请按1+Enter!n);printf(ttt2:个人信息查询请按2+Enter!n);printf(ttt3:存取款记录请按3+Enter!n);printf(ttt4:返回请按4+Enter!n);printf(请选择:);dosc
25、anf(%d,&i); switch(i)case 1:system(cls);chaxun1();break; case 2:system(cls);chaxun2();break; case 3:system(cls);chaxun3();break;case 4:system(cls);bu();break;default:printf(输入有误,请重新输入);while(i!=0);void change()FILE *fp;void bu();struct per memM;int i,len,j,k,flag=0;char zh120,mm120,mm220,mm320;fp=fo
26、pen(d:帐目.txt,rb+);if(fp=NULL)printf(cannot open!n);return;printf(请输入你的帐号:);scanf(%s,zh1);i=0;while(!feof(fp)fread(mem+i,sizeof(struct per),1,fp);i+;rewind(fp);len=i-1;for(i=0;ilen;i+)if(strcmp(memi.zh,zh1)=0)break; while(flag=0)printf(请输入你的密码:); k=0; while(1)mm1k=getch();if(mm1k=13)break;putchar(*);
27、k+; mm1k=0;printf(n);if(strcmp(memi.mm,mm1)=0)flag=1;elseprintf(输入有误,请重新输入。n);b1:printf(请输入你要重设的密码:);k=0; while(1)mm2k=getch();if(mm2k=13)break;putchar(*);k+; mm2k=0;printf(n);printf(请再次输入:);k=0; while(1)mm3k=getch();if(mm3k=13)break;putchar(*);k+; mm3k=0;printf(n);if(strcmp(mm2,mm3)=0)printf(修改成功!n
28、);j=0; while(!feof(fp)fread(&memj,sizeof(struct per),1,fp);j+;rewind(fp); strcpy(memi.mm,mm2); for(j=0;jlen;j+) fwrite(&memj,sizeof(struct per),1,fp);elseprintf(输入有误。n);goto b1;rewind(fp);fclose(fp); printf(n操作时间:n);time_t now;now=time(NULL);printf(%sn,ctime(&now); printf(按任何键返回菜单.n);getch();system(
29、cls); bu();void zhuanzh()FILE *fp,*fp2;void bu();struct per num128; char zh20; char zh120; char mm20; int money,i=1,j,k,len; fp=fopen(d:帐目.txt,rb);if(fp=NULL)printf(还没有一个人申请帐号.n); printf(输入任何键返回菜单.n); getch();goto end; printf(请输入你的帐号:); scanf(%s,zh); printf(密码:); j=0; while(1)mmj=getch();if(mmj=13)b
30、reak;putchar(*);j+;mmj=0;printf(n);for(i=0;!feof(fp);i+)fread(num+i,sizeof(struct per),1,fp);len=i-1;rewind(fp);j=0; while(!feof(fp) fread(num+j,sizeof(struct per),1,fp); if(strcmp(zh,numj.zh)=0&strcmp(mm,numj.mm)=0) break;j+;if(feof(fp)!=0) printf(帐号不存在!n); printf(按任何键返回菜单.n); getch(); goto end;printf(请输入你要转帐的帐号:); scanf(%s,zh1);rewind(fp);k=-1;for(i=0;ilen;i+)