資源描述:
《C語(yǔ)言水電費(fèi)管理系統(tǒng).doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、C語(yǔ)言水電費(fèi)管理系統(tǒng)#include#include#include#defineN100#definew1.8//水1.8元/噸#definee0.5//電0.5元/structResidentinf{intnumber;//住戶門牌號(hào)charname[20];//戶主姓名float*wanum,*elnum;//用水(噸)、電(度)表示數(shù)floatamonney,*emoney;//總共的水電費(fèi)用,每月的水電費(fèi)用char*time;//收費(fèi)時(shí)間}Re[N];intnum;//
2、數(shù)據(jù)個(gè)數(shù)Residentinf*p;//指向結(jié)構(gòu)體的指針voidAdddataFunc();voidStatisdataFunc();voidQuerydataFunc();voidSavedataFunc();voidSortdataFunc();voidModifydataFunc();voidScandataFunc();voidCaldataFunc();//主函數(shù)voidmain(){intsele;sele=1;while(sele){system("cls");//清屏printf("***********Main****
3、*******");printf("**");printf("*1:住戶登記*");printf("**");printf("*2:統(tǒng)計(jì)*");printf("**");printf("*3:排序*");printf("**");printf("*4:刪除*");printf("**");printf("*5:查詢*");printf("**");printf("*6:修改*");printf("**");printf("*7:退出*");printf("****************************");printf("Ch
4、ooseFunction(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;case7:exit(0);}printf("Pleasepressanykeytoco
5、ntinue");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)->wanum,&(p+i)->elnum,&(p+i)->emoney,(p+i)->time);}fclose
6、(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)->amoney+=(p+i)->emoney;}SavedataFunc()}voidSavedataFunc(){FILE*fp
7、;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+i)->time);}fclose(fp);}voidAdddataFunc(){intn,i;Rere;printf("請(qǐng)輸入新用戶信息");syste
8、m("cls");for(i=0;inumber=re.number;printf