《简易水电费管理系统源程序代码.pdf》由会员分享,可在线阅读,更多相关《简易水电费管理系统源程序代码.pdf(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精心打造 未来1 简易水电费管理系统源程序代码 法一:#include#include#include struct member char no100;char name20;char password20;float wfee;float efee;memb;void newadd(int n)int t,i;fseek(fp,0,SEEK_END);printf(新添人数:);scanf(%d,&t);for(i=0;i输入卡号:);scanf(%s,a);int i=0;rewind(fp);while(1)fread(&memb,sizeof(struct member),1,fp)
2、;if(feof(fp)|memb.no=a)break;i+;if(!feof(fp)printf(卡号:);printf(%sn,memb.no);printf(姓名:);printf(%sn,memb.name);printf(水费:);printf(%fn,memb.wfee);精心打造 未来2 printf(电费:);printf(%fn,memb.efee);else printf(查无此人n);void delete(int n)char c100;printf(删除的卡号:);scanf(%s,c);if(fp1=fopen(temp.bin,wb)=NULL)printf(不
3、能建立临时文件,无法删除n);rewind(fp);while(1)fread(&memb,sizeof(struct member),1,fp);if(feof(fp)break;if(memb.no!=c)fwrite(&memb,sizeof(struct member),1,fp1);fclose(fp1);fclose(fp);remove(member.bin);rename(temp.bin,member.bin);fp=fopen(member.bin,rb+);main()char a100;char b20;FILE*fp;printf(欢迎进入水电费管理系统n)int i
4、=0,sel=1;if(fp=fopen(member.bin,wb+)=NULL)printf(不能建立 member.bin 文件n);return(0);while(sel!=0)printf(|1|2|3|4|n);printf(|-|n);printf(|新添成员|查找个人信息|删除成员|退出|n);fseek(fp,0,SEEK_END);scanf(%d,&sel);switch(sel)case 1:newadd(sel);break;clscr();exit(0);精心打造 未来3 case 2:printf(请输入您的卡号:);printf(%s,a);printf(请输入
5、您的密码:);puts(b);while(strcmp(a,memb.no)=0&strcmp(b,memb.password)=0)look(sel);printf(您的输入有误n);break;clscr();exit(0);case 3:delete(sel);break;clscr();exit(0);法二:#include#include#include#include#include struct member char no100;char name20;char password20;float wfee;float efee;memb;void newadd(int n)in
6、t t,i;FILE*fp;fp=fopen(e:member.bin,a);fseek(fp,0,SEEK_END);printf(新添人数:);scanf(%d,&t);for(i=0;i输入卡号:);scanf(%s,a);i=0;rewind(fp);while(1)fread(&memb,sizeof(struct member),1,fp);if(feof(fp)|strcmp(memb.no,a)=0)break;i+;if(!feof(fp)printf(卡号:);printf(%sn,memb.no);printf(姓名:);printf(%sn,memb.name);pri
7、ntf(水费:);printf(%fn,memb.wfee);printf(电费:);printf(%fn,memb.efee);else printf(查无此人n);getch();fclose(fp);void dele(int n)char c100;FILE*fp,*fp1;fp=fopen(e:member.bin,rb);printf(删除的卡号:);scanf(%s,c);if(fp1=fopen(temp.bin,wb)=NULL)printf(不能建立临时文件,无法删除n);rewind(fp);while(1)fread(&memb,sizeof(struct member
8、),1,fp);if(feof(fp)break;if(strcmp(memb.no,c)!=0)fwrite(&memb,sizeof(struct member),1,fp1);fclose(fp1);fclose(fp);精心打造 未来5 remove(member.bin);rename(temp.bin,member.bin);fp=fopen(member.bin,rb+);main()char a100;char b20;int i=0,sel=1;FILE*fp;printf(欢迎进入水电费管理系统n);if(fp=fopen(e:member.bin,wb)=NULL)printf(不能建立 member.bin 文件n);return(0);while(sel!=0)printf(|1|2|3|4|n);printf(|-|n);printf(|新添成员|查找个人信息|删除成员|退出|n);fseek(fp,0,SEEK_END);scanf(%d,&sel);printf(sel=%dn,sel);switch(sel)case 1:newadd(sel);system(cls);break;case 2:look(sel);system(cls);break;case 3:dele(sel);system(cls);break;