| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 569 人关注过本帖
标题:SOS请帮忙~~~~~~~
取消只看楼主 加入收藏
Tina
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2004-12-15
收藏
 问题点数:0 回复次数:0 
SOS请帮忙~~~~~~~
SOS!请高手帮忙~~~~~~

我们要做一个“模拟储蓄所”的C语言程序设计

要求:开户处理;存款处理;取款处理;销户处理;利息计算;修改密码;帐目维护。

我自己编了一个,但销户和修改密码、账目维护这几个功能实现不了。

请各位高手帮帮忙吧。

#include<stdio.h> #define SIZE sizeof(acc) int a; struct acc{ int number; char name; int password; float money;}acc; main() {FILE *fp; fp=fopen("accounts","wb"); fclose(fp);clrscr(); printf("\t============Wlcome=To=Use=This=Program==================\n"); printf("\t| |\n "); printf("\t| $$$$$ $$ $$$ $ $ $$ |\n "); printf("\t| $ $ $ $ $ $ $ $ $$ |\n "); printf("\t| $ $ $ $ $ $ $ $ $ |\n "); printf("\t| $ $ $ $ $ $ $ $ $ |\n "); printf("\t| $$$$$ $$$$$$ $ $ $ $$ |\n "); printf("\t| $ $ $ $ $ $ $ $ $ |\n "); printf("\t| $ $ $ $ $ $ $ $ $ |\n "); printf("\t| $ $ $ $ $ $ $ $ $$ |\n "); printf("\t| $$$$$ $ $ $ $$$ $ $$ |\n "); printf("\t| |\n"); printf("\t==================Made=By=Tina=Tang=====================\n"); printf("Please choose your service:"); do{printf("\n 1.open a account 2.deposit\n"); printf("\n 3.draw the money 4.inquire\n"); printf("\n 5.delete a account 6.password modify\n"); printf("\n 6.interest 8.exit \n"); scanf("%d",&a); switch(a) { case 1: creat();break; case 2: deposit();break; case 3: public();break; case 4: public();break; case 5: public();break; case 6: public();break; case 7: public();break; default: break;}} while(a!=8); printf("Thank you for using this program! See you next time! ^-^");} creat() {int x=0,y,i=1; static int k=1000; float m; FILE *fp; cuprintf("\n Please input your name:"); scanf("%s",&acc.name); do {printf("\n Please input your password:"); scanf("%d",&x); printf("\n please input your password again:"); scanf("%d",&y); if(x==y) acc.password=x; else {printf("ERROR!"); i++;}} while(x!=y&&i<=3); if(x==0) {printf("Eorror!Please input again!"); goto cuo;} printf("\n Please input the money you want to reserve:"); scanf("%f",&m); acc.money=m; k++; printf("\nNo. Name Money\n"); printf("\n%d %c %f\n",k,acc.name,acc.money); acc.number=k; fp=fopen("accounts","wb"); if((fp=fopen("account","wb"))==NULL) {printf("Can not open the account."); exit(0);} fwrite(&acc,SIZE,1,fp); fclose(fp);} deposit() { float r; char n,ch; FILE *fp; clrscr(); printf("\nPlease input your name:"); scanf("%s",&n); fp=fopen("accounts","wb"); ch='a';while(ch!=EOF) {if(n==acc.name) {printf("Please input the money you want to reserve:"); scanf("%f",&r); acc.money=acc.money+r; printf("No. Name Money \n"); printf("%d %c %f\n",acc.number,acc.name,acc.money); ch=fgetc(fp);}}fclose(fp);} public() {int z,p,m,pp,xx; float mm,interest; char n,l,ch; FILE *fp; clrscr(); printf("\nPlease input your number:"); scanf("%d",&z); printf("\nPlease input your name:"); scanf("%s",&n); printf("\nPlease input your password:"); scanf("%d",&p); fp=fopen("accounts","wb"); ch='a'; while(ch!=EOF) {if(z==acc.number&&n==acc.name&&p==acc.password) {if(a==3) {printf("\n Please input the money you want to draw:"); scanf("%f",&mm); if(acc.money<=mm) {printf("Sorry, the money in your account is not enough."); ch=fgetc(fp);break;} else acc.money=acc.money-mm; printf("\n No. Name Money\n"); printf("\n %d %c %f \n",acc.number,acc.name,acc.money); ch=fgetc(fp);} else if(a==4) {printf("\n No. Name Money\n"); printf("\n %d %c %f\n",acc.number,acc.name,acc.money); ch=fgetc(fp);} else if(a==5) {printf("Are you sure you want to delete the account? y/n"); scanf("%c",&l); if(l=='y') {printf("The account has been deleted."); acc.number=0; acc.name='0'; acc.password=0; acc.money=0;} else if(l=='n') {printf("Your account has been reserve."); ch=fgetc(fp);}} else if(a==6) {acc.password=0; printf("Please input the new password:"); scanf("%d",&pp); printf("Please input the new password again:"); scanf("%d",&xx); if(pp==xx) acc.password=pp; else {printf("ERROR!\n"); ch=fgetc(fp);}} else if(a==7) { interest=acc.money*0.006; printf("Your interest is:%f",interest); ch=getc(fp);} fseek(fp,0,2);} else{printf("Information error!\n"); fseek(fp,0,2); ch=fgetc(fp);}} fclose(fp); }

搜索更多相关主题的帖子: SOS 
2004-12-15 09:40
快速回复:SOS请帮忙~~~~~~~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019599 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved