版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上#include<stdio.h> /*引用庫(kù)函數(shù)*/#include<stdlib.h>#include<string.h>#include<conio.h>#include<time.h>#define ZHANGHUSHU 10#define JIAOYISHU 20int caidan();/*登錄注冊(cè)菜單*/void zhuce();void denglu();void baocunshuju();int menu();/*主菜單*/void cunkuan();void qukuan();void
2、 zhuanzhang();void chaxun();void xiugaimima();struct JiaoYi /*定義交易結(jié)構(gòu)體*/ char shijian50;/*時(shí)間*/ char leixing3;/*類型*/ float jine; /*金額*/ float yue;/*余額*/;struct ZhangHu /*定義賬戶結(jié)構(gòu)體*/char xingming17;/*姓名*/char zhanghao12;/*賬號(hào)*/char shenfenzheng19; /*身份證*/char mima7; /*密碼*/float yue; /*余額*/struct JiaoYi ji
3、aoyiJIAOYISHU; /*在賬戶的結(jié)構(gòu)體中在定義交易的結(jié)構(gòu)體*/int jiaoyishu;struct ZhangHu zhanghuZHANGHUSHU; /*定義賬戶數(shù)來(lái)確定賬戶這一結(jié)構(gòu)體中有多少個(gè)體*/int j; /*當(dāng)前賬戶*/int zhanghushu;int k;/*交易帳號(hào)*/int jiaoyishu;void xianshizhanghu();int caidan()/*菜單函數(shù)*/ char c; do system("cls"); /*每次選擇運(yùn)行前清屏*/ printf("tt =歡迎使用ATM系統(tǒng)=nn"); /*
4、菜單選擇*/ printf("tt * 1. 注冊(cè)* *n"); printf("tt * 2. 登錄 *n"); printf("tt * 3. 保存數(shù)據(jù) *n"); printf("tt * 0. 退出 *n"); printf("tt =n"); printf("ttt請(qǐng)作出選擇(0-3):"); c=getchar(); /*讀入選擇*/ while(c<'0'|c>'3'); return(c-'0');
5、/*c變?yōu)榭蘸蠓祷刂匦逻x擇*/*根據(jù)主菜單的返回值來(lái)確定主函數(shù)的值*/void zhuce()printf("ntt請(qǐng)輸入姓名:"); scanf("%s",zhanghuzhanghushu.xingming); printf("ntt請(qǐng)輸入帳號(hào):"); scanf("%s",zhanghuzhanghushu.zhanghao); do printf("ntt請(qǐng)輸入身份證:"); scanf("%s",zhanghuzhanghushu.shenfenzheng); if
6、(strlen(zhanghuzhanghushu.shenfenzheng)=18) break; else printf("ntt身份證必須是18,請(qǐng)重新輸入!"); while(1); do printf("ntt請(qǐng)輸入密碼:"); scanf("%s",zhanghuzhanghushu.mima); if(strlen(zhanghuzhanghushu.mima)=6) break; else printf("ntt密碼必須是6位,請(qǐng)重新輸入!"); while(1); zhanghuzhanghush
7、u.yue=0; zhanghuzhanghushu.jiaoyishu=0; zhanghushu+; xianshizhanghu();void xianshizhanghu() /*顯示賬戶函數(shù)來(lái)顯示所輸入的賬戶*/ int i; for(i=0;i<zhanghushu;i+) printf("nnt帳號(hào)t姓名t身份證tt密碼t余額n"); printf("t%st%st%st%st%.2fn",zhanghui.zhanghao,zhanghui.xingming,zhanghui.shenfenzheng,zhanghui.mima,z
8、hanghui.yue); system("pause"); void denglu() /*登錄函數(shù)*/ char zhanghao12,mima7; int i=0; int mimacishu=1; printf("ntt請(qǐng)輸入帳號(hào):"); scanf("%s",zhanghao); while(strcmp(zhanghao,zhanghui.zhanghao)!=0&&i<zhanghushu) i+; /*/ if(i=zhanghushu) return; do printf("ntt請(qǐng)輸
9、入密碼:"); scanf("%s",mima); if(strcmp(mima,zhanghui.mima)!=0) if(mimacishu=3) printf("你已輸入錯(cuò)誤三次,你不能在輸."); system("pause"); return; else printf("密碼錯(cuò)誤請(qǐng)重新輸入:"); mimacishu+; else break; while(1); for(;) switch(menu() /*選擇判斷*/ case 1: cunkuan(); break; case 2: qu
10、kuan(); break; case 3: zhuanzhang(); break; case 4: chaxun(); break; case 5: xiugaimima(); break; case 0: return; void baocunshuju()/*保存數(shù)據(jù)*/ int i,j; FILE *fp; char filename20; printf("ttt將數(shù)據(jù)保存到一個(gè)文本文件中n");/*輸入文件名*/ printf("ttt請(qǐng)輸入文件名"); fflush(stdin); scanf("%s",filename
11、); if(fp=fopen(filename,"w")=NULL)/*打開文件*/ printf("無(wú)法創(chuàng)建此文件n"); system("pause"); return; fprintf(fp,"%dn",zhanghushu);/*循環(huán)寫入數(shù)據(jù)*/ printf("t帳號(hào)tt姓名tt身份證tt密碼t余額t交易數(shù)"); for(i=0;i<zhanghushu;i+) fprintf(fp,"t%15s%10s%20s%10st%10.2ft%5dn",zhangh
12、ui.zhanghao,zhanghui.xingming,zhanghui.shenfenzheng,zhanghui.mima,zhanghui.yue,zhanghui.jiaoyishu); for(j=0;j<zhanghui.jiaoyishu;j+) fprintf(fp,"%30s%10s%10.2f%10.2fn",zhanghui.jiaoyij.shijian,zhanghui.jiaoyij.leixing,zhanghui.jiaoyij.jine,zhanghui.jiaoyij.yue); fclose(fp);void duqushuj
13、u() int i,j; FILE *fp; char filename20; printf("nnnt請(qǐng)輸入欲讀入數(shù)據(jù)的文件名:n"); fflush(stdin); gets(filename); if(strlen(filename)=0) return; else if(fp=fopen(filename,"r")=NULL)/*打開文件*/ printf("無(wú)法打開此文件n"); system("pause"); return; else printf("tt成功打開文件.n"); g
14、etch(); fscanf(fp,"%dn",zhanghushu); for(i=0;i<zhanghushu;i+) fscanf(fp,"%15s%10s%20s%10ft%10f%5dn", zhanghui.zhanghao, zhanghui.xingming, zhanghui.shenfenzheng, zhanghui.mima, &zhanghui.yue, &zhanghui.jiaoyishu); for(j=0;j<zhanghui.jiaoyishu;j+) fgets(zhanghui.jiao
15、yij.shijian,30,fp); fscanf(fp,"%5s%10ft%10fn",zhanghui.jiaoyij.leixing, &(zhanghui.jiaoyij.jine), &(zhanghui.jiaoyij.yue); fclose(fp);int menu() char c; do system("cls"); printf("nnt= 歡迎使用 XXX銀行ATM =nn"); printf("t=請(qǐng)選擇服務(wù)=n"); printf("t* *n");
16、 printf("t* 1 實(shí)時(shí)存款 2 取款服務(wù) *n"); printf("t* *n"); printf("t* 3 轉(zhuǎn)賬服務(wù) 4 查詢 *n"); printf("t* *n"); printf("t* 5 修改密碼 6 退出 *n"); printf("t* *n"); printf("t=n"); printf("ttt請(qǐng)作出選擇(1-7):"); c=getchar(); /*讀入選擇*/ system("pau
17、se"); while(c<'1'|c>'7'); return(c-'0'); /*c變?yōu)榭蘸蠓祷刂匦逻x擇*/void cunkuan() /*存款函數(shù)*/ float cunkuanjine;/*輸入的存款金額*/ int k; int i; char t30; time_t rawtime; struct tm *timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); strcpy(t,asctime(timeinfo); for(i=0;ti!=
18、'0'i+) if(ti='n') ti='0' break; printf("請(qǐng)輸入存款金額(存款金額必須大于0,不超過10000,必須是100元的面額n"); scanf("%f",&cunkuanjine); if(cunkuanjine<=0|cunkuanjine>1000|(int)cunkuanjine%100!=0) printf("金額不符合要求,請(qǐng)重新選擇"); return; else k=zhanghuj.jiaoyishu; strcpy(z
19、hanghuj.jiaoyik.shijian,t); strcpy(zhanghuj.jiaoyik.leixing,"存"); zhanghuj.jiaoyik.jine=cunkuanjine; zhanghuj.yue+=cunkuanjine; zhanghuj.jiaoyik.yue=zhanghuj.yue; zhanghuj.jiaoyishu+; printf("nttt您本次存了%.2f元n",cunkuanjine); printf("nttt您的余額為%.2f元n",zhanghuj.yue); printf(
20、"n時(shí)間為:%sn",zhanghuj.jiaoyik.shijian); printf("n類型為:%sn",zhanghuj.jiaoyik.leixing); system("pause"); void qukuan() /*取款函數(shù)*/int k;/*交易下標(biāo)*/ float qukuanjine; int i; char t30; time_t rawtime; struct tm *timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); strcpy(
21、t,asctime(timeinfo); for(i=0;ti!='0'i+) if(ti='n') ti='0' break; printf(" 取款服務(wù) n"); printf("t=請(qǐng)選擇服務(wù)=n"); printf("t* *n"); printf("t* 1 100 2 200 *n"); printf("t* *n"); printf("t* 3 500 4 1000 *n"); printf("t* *n
22、"); printf("t* 5 其他金額 6 返回主菜單 *n"); printf("t* *n"); printf("t=n"); scanf("%f",&qukuanjine); if(qukuanjine<=0|qukuanjine>10000|(int)qukuanjine%100!=0) printf("金額不符合要求,請(qǐng)重新選擇"); return; else if(zhanghuj.yue<qukuanjine) printf("你的
23、賬戶余額不足,不能完成這項(xiàng)操作。"); return; k=zhanghuj.jiaoyishu; strcpy(zhanghuj.jiaoyik.shijian,t); strcpy(zhanghuj.jiaoyik.leixing,"取"); zhanghuj.jiaoyik.jine=qukuanjine; zhanghuj.yue-=qukuanjine; zhanghuj.jiaoyik.yue=zhanghuj.yue; zhanghuj.jiaoyishu+; printf("nttt您本次取款%.2f元n",qukuanjine
24、); printf("nttt您的余額為%.2f元n",zhanghuj.yue); printf("n時(shí)間為:%sn",zhanghuj.jiaoyik.shijian); printf("n類型為:%sn",zhanghuj.jiaoyik.leixing); system("pause"); void zhuanzhang() float zhuanzhangjine; int i; int l=0; char t30,zhuanzhangzhanghao12; char sign='n' t
25、ime_t rawtime; struct tm *timeinfo; time(&rawtime); timeinfo=localtime(&rawtime); strcpy(t,asctime(timeinfo); for(i=0;ti!='0'i+) if(ti='n') ti='0' printf("請(qǐng)輸入你要轉(zhuǎn)入的帳號(hào):"); scanf("%s",zhuanzhangzhanghao); while(strcmp(zhanghul.zhanghao,zhuanzhangzhang
26、hao)!=0&&l<zhanghushu) l+; if(l=zhanghushu) printf("你輸入的用戶不存在!n"); system("pause"); return; printf("n該賬戶戶主姓名為%sn,是否確認(rèn)轉(zhuǎn)賬Y/N?",zhanghuj.xingming); scanf("tt%c",&sign); /*輸入判斷*/ if(sign!='y'&&sign!='Y') /*判斷*/ return; else d
27、o printf("n請(qǐng)輸入轉(zhuǎn)賬金額(大于100不超過5000):"); scanf("%f",&zhuanzhangjine); if(zhuanzhangjine<100|zhuanzhangjine>5000) printf("輸入金額不對(duì),請(qǐng)重新輸入!"); system("pause"); return; if(zhanghuj.yue<=0|zhanghuj.yue<zhuanzhangjine) printf("賬戶余額不足n"); system(&
28、quot;pause"); return; else k=zhanghuj.jiaoyishu; strcpy(zhanghuj.jiaoyik.shijian,t); strcpy(zhanghuj.jiaoyik.leixing,"轉(zhuǎn)賬"); zhanghuj.jiaoyik.jine=zhuanzhangjine; zhanghuj.yue-=zhuanzhangjine; zhanghuj.jiaoyik.yue=zhanghuj.yue; zhanghuj.jiaoyishu+; printf("ntt你本次轉(zhuǎn)了%0.2f元n",zh
29、uanzhangjine); printf("ntt你的余額為%0.2f元n",zhanghuj.yue); printf("ntt時(shí)間為:%sn",zhanghuj.jiaoyik.shijian); printf("ntt類型為:%sn",zhanghuj.jiaoyik.leixing); system("pause"); while(0); printf("nntt轉(zhuǎn)賬成功nn"); system("pause"); void xiugaimima() /*修改密碼函
30、數(shù)*/ char mima17,mima27; do do printf("nnntt請(qǐng)輸入密碼:"); scanf("%s",mima1); if(strlen(mima1)=6) break; else printf("nntt密碼必須是6位,請(qǐng)重新輸入!"); while(1); do printf("nnntt請(qǐng)確認(rèn)密碼:"); scanf("%s",mima2); if(strlen(mima2)=6) break; else printf("輸入密碼必須是6位請(qǐng)輸入密碼:&
31、quot;); while(1); if(strcmp(mima1,mima2)=0 ) /*判斷第二次輸入的密碼是否與第一次的一致*/ break; else printf("nntt*|兩次密碼不相等請(qǐng)重新輸入:nn"); while(1); strcpy(zhanghuj.mima,mima1); printf("nntt修改密碼成功nn"); getch(); system("pause");int chaxuncaidan();/*查詢菜單*/void chaxunyue();void chaxuncunkun();void
32、 chaxunqukun();void chaxunzhuangzhan();void chaxunjiaoyi();void duqushuju();void chaxun() /*查詢函數(shù)*/ for(;) switch(chaxuncaidan() /*選擇判斷*/ case 1: chaxunyue(); break; case 2: chaxuncunkun(); break; case 3: chaxunqukun(); break; case 4: chaxunzhuangzhan(); break; case 5: chaxunjiaoyi(); break; case 0:
33、return; int chaxuncaidan()/*菜單函數(shù)*/char c; do system("cls"); /*每次選擇運(yùn)行前清屏*/ printf("tt *查詢菜單*nn"); /*菜單選擇*/ printf("tt *| 1. 查詢余額|n"); printf("tt *| 2. 查詢存款記錄|n"); printf("tt *| 3. 查詢?nèi)】钣涗泑n"); printf("tt *| 4. 查詢轉(zhuǎn)賬記錄|n"); printf("tt *| 5
34、. 查詢交易情況|n"); printf("tt *| 0. 退出 |n"); printf("tt *n"); printf("ttt請(qǐng)作出選擇(0-5):"); c=getchar(); /*讀入選擇*/ while(c<'0'|c>'5'); return(c-'0'); /*c變?yōu)榭蘸蠓祷刂匦逻x擇*/ void chaxunyue()/*查詢余額函數(shù)*/ printf("nt您的余額為%.2f元n",zhanghuj.yue); syst
35、em("pause");void chaxuncunkun() /*查詢存款函數(shù)*/ int i; printf("tt *存款查詢記錄*nn"); printf("t帳號(hào)t姓名t交易類型t交易時(shí)間tt金額t余額n"); for(i=0;i<zhanghuj.jiaoyishu;i+) if(strcmp(zhanghuj.jiaoyii.leixing,"存")=0) printf("t%st%st%st%st%.2ft%.2fnn",zhanghuj.zhanghao, zhanghu
36、j.xingming,zhanghuj.jiaoyii.leixing, zhanghuj.jiaoyii.shijian,zhanghuj.jiaoyii.jine, zhanghuj.jiaoyii.yue); else; system("pause");void chaxunqukun() /*查詢?nèi)】詈瘮?shù)*/ int i; printf("tt *取款查詢記錄*nn"); printf("t帳號(hào)t姓名t交易類型t交易時(shí)間tt金額t余額n"); for(i=0;i<zhanghuj.jiaoyishu;i+) if(strcmp(zhanghuj.jiaoyii.leixing,"取")=0) printf("t%st%st%st%st%.2ft%.2fnn",zhanghuj.zhanghao, zhan
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度智慧校園運(yùn)營(yíng)管理承包經(jīng)營(yíng)合同書范文4篇
- 二零二五年度抗裂抹灰材料勞務(wù)分包協(xié)議3篇
- 2025年度水利工程打樁施工合同范本(二零二五版)4篇
- 2025版汽車銷售場(chǎng)地租賃與客戶滿意度提升合同4篇
- 2024版施工小修簡(jiǎn)易合同
- 2025年環(huán)保型變壓器研發(fā)與銷售合作協(xié)議范本2篇
- 2025年度智慧社區(qū)建設(shè)項(xiàng)目承包清工勞務(wù)合同模板4篇
- 二零二五版航空航天精密模具研發(fā)生產(chǎn)協(xié)議3篇
- 2025年度房地產(chǎn)項(xiàng)目合作開發(fā)合同示范文本4篇
- 2025年度美容美發(fā)行業(yè)線上線下融合發(fā)展合同4篇
- 2024年上海核工程研究設(shè)計(jì)院股份有限公司招聘筆試沖刺題(帶答案解析)
- 眼的解剖結(jié)構(gòu)與生理功能課件
- 2024年銀行考試-興業(yè)銀行筆試參考題庫(kù)含答案
- 泵站運(yùn)行管理現(xiàn)狀改善措施
- 2024屆武漢市部分學(xué)校中考一模數(shù)學(xué)試題含解析
- SYT 0447-2014《 埋地鋼制管道環(huán)氧煤瀝青防腐層技術(shù)標(biāo)準(zhǔn)》
- 浙教版七年級(jí)下冊(cè)科學(xué)全冊(cè)課件
- 弧度制及弧度制與角度制的換算
- 瓦楞紙箱計(jì)算公式測(cè)量方法
- DB32-T 4004-2021水質(zhì) 17種全氟化合物的測(cè)定 高效液相色譜串聯(lián)質(zhì)譜法-(高清現(xiàn)行)
- DB15T 2724-2022 羊糞污收集處理技術(shù)規(guī)范
評(píng)論
0/150
提交評(píng)論