资源描述:
《C语言水电费管理系统》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C语言水电费管理系统#include#include#include#defineN100#definew1.8//水1.8元/吨#definee0.5//电0.5元/structResidentinf{intnumber;//住户门牌号charname[20];//户主姓名float*wanum,*elnum;//用水(吨)、电(度)表示数floatamonney,*emoney;//总共的水电费用,每月的水电费用char*time;//收费时间}Re[N
2、];intnum;//数据个数Residentinf*p;//指向结构体的指针voidAdddataFunc();voidStatisdataFunc();voidQuerydataFunc();voidSavedataFunc();voidSortdataFunc();voidModifydataFunc();voidScandataFunc();voidCaldataFunc();//主函数voidmain(){intsele;sele=1;while(sele){system("cls");//清屏print
3、f("***********Main***********");printf("**");printf("*1:住户登记*");printf("**");printf("*2:统计*");printf("**");printf("*3:排序*");printf("**");printf("*4:删除*");printf("**");printf("*5:查询*");printf("**");printf("*6:修改*");printf("**");printf("*7:退出*");printf("********
4、********************");printf("ChooseFunction(1-7)[]bb");scanf("%d",&sele);switch(sele){case1:AdddataFunc();break;case2:StatisdataFunc();break;case3:SortdataFunc();break;case4:DeletedataFunc();break;case5:QuerydataFunc();break;case6:ModifydataFunc();break;ca
5、se7:exit(0);}printf("Pleasepressanykeytocontinue");getchar();getchar();}}voidScandataFunc(){inti,j;FILE*fp;fp=fopen("Data.txt","r");for(i=0;inumber,(p+i)->name,&(p+i)->amoney);for(j=0;j<100;j++)fscanf(fp,"%d%d%d%s",&(p+i)->
6、wanum,&(p+i)->elnum,&(p+i)->emoney,(p+i)->time);}fclose(fp);}voidCaldataFunc(){inti,j;fp=fopen("Data.txt","w");for(i=0;iemoney[j]=((p+i)->wanum[j]-(p+i)->wanum[j-1])*w+((p+i)->elnum[j]-(p+i)->elnum[j-i])*e;(p+i)->amoney=0;(p+i)
7、->amoney+=(p+i)->emoney;}SavedataFunc()}voidSavedataFunc(){FILE*fp;fp=fopen("Data.txt","w");inti,j;for(i=0;inumber,(p+i)->name,(p+i)->amoney);for(j=0;j<100;j++)fprintf(fp,"%d%d%d%s",(p+i)->wanum,(p+i)->elnum,(p+i)->emoney,(p+
8、i)->time);}fclose(fp);}voidAdddataFunc(){intn,i;Rere;printf("请输入新用户信息");system("cls");for(i=0;inumber=re.number;printf