網站首頁 編程語言 正文
本文實例為大家分享了C語言實現銀行管理系統的具體代碼,供大家參考,具體內容如下
銀行管理系統主要有五個模塊組成:
1、查詢賬戶信息
2、存錢
3、取款
4、轉賬
5、退出系統
測試文件:(首先在cpp文件所在目錄下添加這個文件,運行程序會自動添加文件,但是需要輸入這些數據)
代碼:
#include? ?/*I/O函數*/ #include ?/*其它說明*/ #include ?/*字符串函數*/ #define max 100 #define LEN 15 ? ? ?/* 賬號和密碼最大字符數,實際請更改*/ #define N 100 ? ? ? ?/* 最大賬戶數,實際請更改*/ int k=1,n=0, m=0;/* n代表當前記錄的學生人數*/ //賬戶信息結構體 struct banker { ? ? char accountNo[LEN]; ? ? char accountName[LEN]; ? ? char Password[LEN]; ? ? float Balance; ?? ?char VIPoNormal[LEN]; }bank[N]; void fileWrite(); //存錢 void Save() { ?? ?int item,i;? ?? ?char s1[LEN+1]; //用來輸賬號的? ? ? printf("請輸入需要存錢的賬號\n"); ? ? scanf("%s",&s1); ? ? for(i=0; i jud) ?? ??? ??? ?{ ?? ??? ??? ??? ?printf("輸入不符合規范,請按照注意事項進行輸入"); ?? ??? ??? ??? ?scanf("%f",&wd); ?? ??? ??? ?} ?? ??? ??? ?//取款之后的更新操作 ?? ??? ??? ?bank[item].Balance-=wd; ?? ??? ??? ?fileWrite();? ?? ??? ? ?? ??? ?} ? ? ?? ? ?? ?} ?? ? ?? ?return; } //轉賬 void Transfer() { ?? ??? ?//首先肯定需要查詢一下? ?? ??? ?//先把賬戶信息讀進來?? ?必須輸入該賬號和對應的密碼,輸入錯誤則給出警告? ?? ?int j=0; ? ? FILE * fp; ? ? if((fp=fopen("account.txt","r"))==NULL) ?? ??? ?return ; ?? ?while(fscanf(fp,"%s %s %s %f %s\n",&bank[j].accountNo,&bank[j].accountName,&bank[j].Password,&bank[j].Balance,&bank[j].VIPoNormal)==5)? ?? ?{ ? ? ? ? j++; ? ? } ? ? n=j; ? ? int i=0,item=0,flag=0; ? ? char s1[LEN+1]; /* 以賬號和密碼最長長度+1為準*/ ?//用來輸賬號的? ? ? char s2[LEN+1]; /* 以賬號和密碼最長長度+1為準*/ ?//用來輸密碼的? ? ? printf("請輸入賬號\n"); ? ? scanf("%s",&s1); ? ? for(i=0; i jud || money>bank[item].Balance) ?? ??? ??? ?{ ?? ??? ??? ??? ?printf("輸入不符合規范,請按照注意事項進行輸入"); ?? ??? ??? ??? ?scanf("%f",&money); ?? ??? ??? ?} ?? ??? ??? ?if(strcmp(bank[item].VIPoNormal,"V")==0)? ?? ??? ??? ?{ ?? ??? ??? ??? ?bank[item].Balance-=money*0.005;? ?? ??? ??? ?}else{ ?? ??? ??? ??? ?bank[item].Balance-=money*0.01;? ?? ??? ??? ?} ?? ??? ??? ?bank[item].Balance-=money; ?? ??? ??? ?bank[item2].Balance+=money;? ?? ??? ??? ?fileWrite(); ?? ??? ??? ?printf("轉賬成功\n"); ?? ??? ?} ? ? ?? ? ?? ?} ?? ? ?? ?return; }? //插入學生信息函數 void insert()? { ? ? int i; ? ? printf("請輸入待增加的賬戶數:"); ? ? scanf("%d",&n); ? ? FILE * fp; ? ? if((fp=fopen("account.txt","at"))==NULL)? ?? ??? ?printf("文件為空!\n"); ? ? for(i=0; i
原文鏈接:https://blog.csdn.net/weixin_45663946/article/details/112756849
相關推薦
- 2023-03-29 詳解C++中菱形繼承的原理與解決方法_C 語言
- 2022-12-05 Python應用開發之實現串口通信_python
- 2022-08-21 如何使用C語言將數字、字符等數據寫入、輸出到文本文件中_C 語言
- 2022-09-01 ASP.NET?Core通用主機的系統配置_實用技巧
- 2022-04-04 快應用開發自定義事件 快應用層級 圖片對象Image 獲取元素的寬高
- 2022-07-28 XML基本概念XPath、XSLT與XQuery函數介紹_XML/RSS
- 2022-11-13 如何使用Python讀取.xlsx指定行列_python
- 2022-02-28 Error: A <Route> is only ever to be used as the ch
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支