




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、include”stdio.h"#include"string。h”include"stdlib。h”#include"conio.h"#include"time.h"#define N 20define M 20#define TRUE 1 #define FALSE 0 define MIN_INPUT ' define MAX_INPUT 127 /127即0x7estruct jilufloat add; /存款金额 float dra; /取款金额 char dname20; /识别账号 char dnum
2、20;/识别姓名 char ope20;/经办人姓名 char time128; /系统当前时间 float sy; /剩余金额;struct depositorchar num20; /客户账号 char name20; /客户姓名 char per20; /用户身份证号 char sec20; /用户密码 float mon; /存款金额 char addr20; /储户地址;void menu();int GetPassword(unsigned char* pszPw,int iMaxSize);/使输入的密码显示为int reads(struct depositor depN);/从
3、文件中读入客户信息int readsc(struct jilu jlM); /从文件读入存款记录int readsd(struct jilu jlM); /从文件读入取款记录void save(struct depositor depN,int n); /保存修改后的客户信息数据void add(); /开户函数void del(); /销户函数void change(); /改密函数void show(); /显示余额函数void show1();/存款void show2();/存款记录void show3();/取款void show4();/取款记录void show5();/清屏函数
4、void show6();void show7(char panduan20);void main() int n; system("color 1e"); while(1) menu(); printf(”n请输入您要选择的操作序号,按回车键确认:"); scanf("d",n); switch(n) case 1: add();break; case 2: show();break; case 3: del();break; case 4: change();break; case 0: exit(0);case 5: show1();br
5、eak;case 6: show2();break; case 7: show3();break;case 8: show4();break;case 9: show6();break; default: printf("n输入错误,请输入列表中存在的序号!n ”);show5();void menu() /菜单函数 printf(”n* 银行个人账户管理系统* ”); printf(”n 1 储户开户"); printf(”n 2 余额查询"); printf("n 3 储户销户"); printf("n 4 密码修改”); pri
6、ntf("n 5 存款");printf("n 6 个人存款记录”);printf(”n 7 取款"); printf("n 8 个人取款记录”); printf("n 0 退出"); printf("n 9 查询所有客户存款记录”); printf("nn* "); int reads(struct depositor depN) / 读取储户内容FILE *fp; int i=0; if(fp=fopen("account.txt”,"r")=NULL) pri
7、ntf("文件打开失败!n"); show5(); return 0; else for(i=0;!feof(fp);i+) fscanf(fp,"n%s s %s %s f sn",,depi.num,depi.per,depi。sec,depi.mon,depi。addr); fclose(fp); return i; int readsc(struct jilu jlM) /读取存款记录 FILE *fp; int i=0; if((fp=fopen("cun.txt",”r")=NULL) prin
8、tf(”文件打开失败!没有任何存款记录n"); return 0; elsefor(i=0;!feof(fp);i+)fscanf(fp,”n%s f s %s %s fn”,jli.dnum,jli.add,jli。dname,jli.ope,jli.time,jli.sy); fclose(fp); return i;int readsd(struct jilu jlM) /读取取款记录 FILE fp; int i=0; if((fp=fopen("qu.txt","r"))=NULL) printf("文件打开失败!没有任何取
9、款记录n"); return 0; elsefor(i=0;!feof(fp);i+)fscanf(fp,”n%s %f %s s s %fn",jli。dnum,jli.dra,jli.dname,jli。ope,jli.time,jli。sy); fclose(fp); return i;void save(struct depositor depN,int n) / 储户保存后信息FILE *fp; int i=0; if(fp=fopen(”account.txt”,"w”))=NULL) printf("文件打开失败!n"); sho
10、w5(); return ; else for(i=0;i<n;i+)fprintf(fp,"ns %s %s s %f sn”,,depi。num,depi.per,depi.sec,depi。mon,depi.addr); fclose(fp);void add()/储户开户/ FILE *fp; unsigned char pw99; struct depositor dep; char panduan20; int iMaxSize=80;system("cls”); if((fp=fopen("account。txt”,"
11、;a"))=NULL) /如果文件已经存在,可以追加储户信息 if(fp=fopen("account.txt”,”w")=NULL) / 文件不存在时,创建新文件,输入储户信息 printf("用户不存在!n"); show5(); return ; printf("n请依次填写储户信息,以回车键作为间隔n"); printf("n账号: ”); scanf("s",); strcpy(panduan,); show7(panduan); fprintf(fp,
12、"n%sn",panduan); printf("n姓名: " ); scanf("s",dep.num); fprintf(fp,"n%sn”,dep。num); printf("n电话:”); scanf("%s",dep.per); fprintf(fp,”n%sn",dep.per); printf("n密码:"); if( GetPassword(pw,iMaxSize) = TRUE ) strcpy(dep。sec,pw); fprintf(fp,”n
13、sn”,dep.sec); printf(”nn请重新输入密码,按回车键确认:"); if( GetPassword(pw,iMaxSize) = TRUE ) while(strcmp(pw,dep。sec)!=0) printf("nn输入的密码错误,请重新输入:”); if( GetPassword(pw,iMaxSize) = TRUE ); printf(”nn金额:"); scanf(”f”,&dep。mon); fprintf(fp,”nfn”,dep。mon); printf(”n住址:"); scanf("%s”,de
14、p.addr); fprintf(fp,”n%sn",dep.addr); if(dep.mon10 ) printf("n 储户金额低于十元,不予开户 n"); show5(); return ; printf(”n*开户成功* "); show5(); fclose(fp);void show() /余额查询 unsigned char pw99; int iMaxSize=80; struct depositor depN; int i,n;char s20;char t20 ; system("cls”); n=reads(dep);
15、printf("n请用户输入账号,密码,用回车隔开,按回车键确认:nn”);scanf(”s”,s); if( GetPassword(pw,iMaxSize) = TRUE )strcpy(t,pw); for(i=0;in;i+) if (strcmp(s,)=0 & strcmp(t,depi.sec)=0) break; if (i>=n |strcmp(t,depi.sec)!=0) printf(”n输入错误n”); show5(); return ; else printf(”n*储户余额如下* "); printf(”n%。2
16、fn", depi。mon); show5(); void show1() /存款 unsigned char pw99; int iMaxSize=80;FILE *fp; int i,n;char s20; char t20 ; struct depositor depN; struct jilu jl; system(”cls"); n=reads(dep); printf(”n请用户输入账号,密码,用回车隔开,按回车键确认:nn”);scanf(”%s",s); if( GetPassword(pw,iMaxSize) = TRUE )strcpy(t,p
17、w); for(i=0;i<n;i+) if (strcmp(s,)=0 &&strcmp(t,depi。sec)=0) break; if (i>=n strcmp(t,depi.sec)!=0) printf("n 输入错误 n”); show5(); return ; else if(fp=fopen("cun。txt”,"a")=NULL) /如果文件已经存在,可以追加储户信息 if(fp=fopen(”cun。txt”,”w”))=NULL) / 文件不存在时,创建新文件,输入储户信息 printf
18、(”记录不存在!n"); show5(); return ; strcpy(jl.dnum,depi。num); fprintf(fp,”n%sn",jl.dnum); printf("n请输入存款金额,并按回车键确认:nn"); scanf("f”,jl。add); fprintf(fp,"n%fn”,jl.add); strcpy(jl.dname,); fprintf(fp,”nsn”,jl。dname); printf("n请输入操作员姓名,并按回车键确认:nn"); scanf(”s&q
19、uot;,jl.ope); fprintf(fp," %s”,jl.ope); _tzset(); _strtime(jl.time); _strdate(jl。time); fprintf(fp,"n%sn”,jl.time); jl.sy=jl.add+depi.mon; fprintf(fp,”n%fn",jl.sy); depi.mon=depi。mon+jl.add; save(dep,n); printf("n您已成功存款.fn”,jl。add); printf("n现在总金额为。fn”,depi。mon); show5(); fc
20、lose(fp);void show2() /存款记录 unsigned char pw99; int iMaxSize=80;FILE fp; int i,n,z,k,l=1;char s20;char t20; struct depositor depN; struct jilu jlM; system(”cls”); z=readsc(jl); n=reads(dep); if((fp=fopen(”cun.txt”,"r")!=NULL) printf(”n请用户输入账号,密码,用回车隔开,按回车键确认:nn"); scanf("%s"
21、,s); if( GetPassword(pw,iMaxSize) = TRUE ) strcpy(t,pw); for(i=0;i<n;i+) if (strcmp(s,)=0 &strcmp(t,depi。sec)=0) break; if (i=n|strcmp(t,depi.sec)!=0) printf(”n 输入错误 n"); show5(); return ; else printf(”n存款记录如下:nn编号 存款金额 存款时间 剩余金额 操作员n"); for(k=0;k<z;k+) if(strcmp(depi。na
22、me,jlk。dname)=0) printf(”n%-8d%-12.f%12s12.fsn",l+,jlk.add,jlk。time,jlk.sy,jlk。ope); show5();else show5(); void show3() /取款 unsigned char pw99; int iMaxSize=80;FILE fp; int i,n;char s20;char t20; struct depositor depN; struct jilu jl; system(”cls”); n=reads(dep); printf(”n请用户输入账号,密码,用回车隔开,按回车键确
23、认:nn");scanf(”%s",s); if( GetPassword(pw,iMaxSize) = TRUE )strcpy(t,pw); for(i=0;i<n;i+) if (strcmp(s,)=0 strcmp(t,depi.sec)=0) break; if (i=n strcmp(t,depi。sec)!=0) printf(”n输入错误 n”); show5(); return ; else if(fp=fopen(”qu.txt","a"))=NULL) /如果文件已经存在,可以追加储户信息 if(
24、fp=fopen(”qu。txt”,”w”)=NULL) / 文件不存在时,创建新文件,输入储户信息 printf("记录不存在!n"); show5(); return ; strcpy(jl.dnum,depi.num); fprintf(fp,"n%sn",jl。dnum); printf(”n请输入取款金额,并按回车键确认:nn"); scanf("%f",jl.dra); if(jl。dra=depi。mon) fprintf(fp,"nf”,jl。dra); strcpy(jl.dname,depi.n
25、ame); fprintf(fp,"nsn",jl。dname); printf("n请输入操作员姓名,并按回车键确认:nn"); scanf(”%s”,jl.ope); fprintf(fp,"nsn",jl.ope); _tzset(); _strtime(jl。time); _strdate(jl.time); fprintf(fp,"nsn",jl。time); jl。sy=depi.monjl。dra; fprintf(fp,"n%fn",jl.sy); depi.mon=depi。m
26、onjl。dra; save(dep,n); printf("n您已成功取款。fn",jl。dra); printf(”n现在总金额为。fn”,depi。mon); show5(); else printf(”n取款金额大于剩余金额,取款失败n"); show5(); fclose(fp);void show4() /取款记录 unsigned char pw99; int iMaxSize=80;FILE *fp; int i,n,z,k,l=1;char s20;char t20; struct depositor depN; struct jilu jlM;
27、 system("cls”); z=readsd(jl); n=reads(dep);if(fp=fopen(”qu.txt",”r"))!=NULL) printf(”n请用户输入账号,密码,用回车隔开,按回车键确认:nn”); scanf(”%s",s); if( GetPassword(pw,iMaxSize) = TRUE ) strcpy(t,pw); for(i=0;i<n;i+) if (strcmp(s,)=0 &&strcmp(t,depi。sec)=0) break; if (i>=n |
28、 strcmp(t,depi.sec)!=0) printf(”n 输入错误 n”); show5(); return ; else printf("n取款记录如下:nn编号 取款金额 取款时间 剩余金额 操作员n"); for(k=0;kz;k+) if(strcmp(,jlk.dname)=0) printf(”n-8d%-12.f-12s12.f%sn”,l+,jlk.dra,jlk。time,jlk.sy,jlk.ope); show5(); else show5();void del() /储户信息删除函数 unsigned char pw99;
29、 int iMaxSize=80;struct depositor depN; char number20;char t20; int n,i,j; system("cls"); n=reads(dep); printf(”n请输入要删除储户账号,密码,用回车隔开,按回车键确认:"); scanf("s”,number); if( GetPassword(pw,iMaxSize) = TRUE )strcpy(t,pw); for(i=0;in;i+) if(strcmp(number,)=0 && strcmp(t,d
30、epi.sec)=0) break; if(i>=n | strcmp(t,depi.sec)!=0)printf("没有找到该储户信息!n"); show5(); return; elsefor(j=i+1;j<n;j+) depj1=depj; save(dep,n-1); printf(”销户成功!n”); show5(); void change() /储户密码更改 unsigned char pw99; int iMaxSize=80;struct depositor depN; int n,i;char t20;char number20; syst
31、em("cls"); printf(”n请输入要更改密码的储户账号,密码,用空格隔开,按回车键确认:n”); scanf(”%s”,number); if( GetPassword(pw,iMaxSize) = TRUE )strcpy(t,pw); n=reads(dep); for(i=0;i<n;i+) if(strcmp(number,)=0 &strcmp(t,depi.sec)=0) break;if(i=n |strcmp(t,depi.sec)!=0)printf("无此储户信息!”); show5(); retur
32、n; printf(”n请输入更改后密码,按回车键确认:n"); scanf(”s",&depi.sec); save(dep,n); printf("n修改成功n"); show5();void show5()/该函数控制清屏 int c; printf("n确认请按1nn"); scanf(”%d",&c); if(c=1) system(”cls"); /函数整体功能为使输入的密码在控制台显示为* 所有功能有此函数实现: pszPw : 保存密码的缓冲 * iMaxSize :最大的密码长度,该长度必须小于缓冲区大小. 返回值为TRUE为成功获取密码。总是返回TRUE */ int GetPassword(unsigned char pszPw,int iMaxSize) unsigned char ch; int i=0; int bIsEcho=TRUE; /while( ! kbhit() & i<iMaxSize ) while( ( ch = (
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论