C语言家庭财务管理系统代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includestdio.h#includestdlib.h#includestring.hstructData{charname[20];charriqi[8];floatmoney;charbeizhu[50];};structlist{structDatainfo;structlist*next;};structlist*Inhead=NULL;structlist*Intail=NULL;structlist*zhichuhead=NULL;structlist*zhichutail=NULL;structlist*temp=NULL;voidchaxun_income();voidchaxun_zhichu();voidxiugai_income();voidxiugai_zhichu();voidSave_income(){FILE*fp;fp=fopen(D:\家庭财务管理.txt,w);structlist*p=Inhead;while(p!=NULL){fwrite(&p-info,sizeof(structData),1,fp);p=p-next;}fclose(fp);}voidSave_zhichu(){FILE*fp;fp=fopen(D:\家庭财务管理支出.txt,w);structlist*p=zhichuhead;while(p!=NULL){fwrite(&p-info,sizeof(structData),1,fp);p=p-next;}fclose(fp);}voidOpen(){FILE*fp;fp=fopen(D:\家庭财务管理.txt,r);if(fp!=NULL){structDatalinshi;while(fread(&linshi,sizeof(structData),1,fp)==1){temp=(structlist*)malloc(sizeof(structlist));temp-info=linshi;temp-next=NULL;if(Inhead==NULL){Inhead=temp;Intail=temp;}else{Intail-next=temp;Intail=temp;}}fclose(fp);}}voidMenu(){system(cls);printf(\n);printf(\n);printf(\n);printf(\n);printf(******************\n);printf(欢迎使用家庭财务管理系统\n);printf(******************\n);printf(\n);printf(1:收入操作\n);printf(2:支出操作\n);printf(3:统计操作\n);printf(0:退出\n);}voidOpenzhichu(){FILE*fp;fp=fopen(D:\家庭财务管理支出.txt,r);if(fp!=NULL){structDatalinshi;while(fread(&linshi,sizeof(structData),1,fp)==1){temp=(structlist*)malloc(sizeof(structlist));temp-info=linshi;temp-next=NULL;if(zhichuhead==NULL){zhichuhead=temp;zhichutail=temp;}else{zhichutail-next=temp;zhichutail=temp;}}fclose(fp);}}voidmingzi(){charchazhao[20];printf(请输入查询的名字);gets(chazhao);structlist*p=Inhead;while(p!=NULL){if(strcmp(p-info.name,chazhao)==0){printf(姓名:);puts(p-info.name);printf(日期:);puts(p-info.riqi);printf(收入:);printf(%.4f\n,p-info.money);printf(备注:);puts(p-info.beizhu);system(PAUSE);}p=p-next;}if(Inhead!=NULL){charpanduan;printf(是否继续查询(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}voidmingzi_zhichu(){charchazhao[20];printf(请输入查询的名字);gets(chazhao);structlist*p=zhichuhead;while(p!=NULL){if(strcmp(p-info.name,chazhao)==0){printf(姓名:);puts(p-info.name);printf(日期:);puts(p-info.riqi);printf(收入:);printf(%.4f\n,p-info.money);printf(备注:);puts(p-info.beizhu);system(PAUSE);}p=p-next;}if(zhichuhead!=NULL){charpanduan;printf(是否继续查询(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}voidmingzi_xiugai_income(){charxiugai[20];printf(请输入修改的名字);fflush(stdin);gets(xiugai);structlist*p=Inhead;while(p!=NULL){if(strcmp(p-info.name,xiugai)==0){fflush(stdin);printf(姓名:);gets(p-info.name);fflush(stdin);printf(日期:);gets(p-info.riqi);fflush(stdin);printf(支出:);scanf(%f,&p-info.money);fflush(stdin);printf(备注:);gets(p-info.beizhu);fflush(stdin);//------}p=p-next;}Save_income();if(Inhead!=NULL){charpanduan;printf(是否继续修改(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}voidmingzi_xiugai_zhichu(){charxiugai[20];printf(请输入修改的名字);fflush(stdin);gets(xiugai);structlist*p=zhichuhead;while(p!=NULL){if(strcmp(p-info.name,xiugai)==0){fflush(stdin);printf(姓名:);gets(p-info.name);fflush(stdin);printf(日期:);gets(p-info.riqi);fflush(stdin);printf(支出:);scanf(%f,&p-info.money);fflush(stdin);printf(备注:);gets(p-info.beizhu);fflush(stdin);//------}p=p-next;}Save_zhichu();if(zhichuhead!=NULL){charpanduan;printf(是否继续修改(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_zhichu();}}}voidriqi(){charchazhao[20];printf(请输入查询的日期);gets(chazhao);structlist*p=Inhead;while(p!=NULL){if(strcmp(p-info.riqi,chazhao)==0){printf(姓名:);puts(p-info.name);printf(日期:);puts(p-info.riqi);printf(收入:);printf(%.4f\n,p-info.money);printf(备注:);puts(p-info.beizhu);system(PAUSE);}p=p-next;}if(Inhead!=NULL){charpanduan;printf(是否继续查询(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_income();}}}voidriqi_zhichu(){charchazhao[20];printf(请输入查询的日期);gets(chazhao);structlist*p=zhichuhead;while(p!=NULL){if(strcmp(p-info.riqi,chazhao)==0){printf(姓名:);puts(p-info.name);printf(日期:);puts(p-info.riqi);printf(收入:);printf(%.4f\n,p-info.money);printf(备注:);puts(p-info.beizhu);system(PAUSE);}p=p-next;}if(zhichuhead!=NULL){charpanduan;printf(是否继续查询(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){chaxun_zhichu();}}}voidriqi_xiugai_income(){charxiugai[20];printf(请输入修改的日期);fflush(stdin);gets(xiugai);structlist*p=Inhead;while(p!=NULL){if(strcmp(p-info.riqi,xiugai)==0){fflush(stdin);printf(姓名:);gets(p-info.name);fflush(stdin);printf(日期:);gets(p-info.riqi);fflush(stdin);printf(支出:);scanf(%f,&p-info.money);fflush(stdin);printf(备注:);gets(p-info.beizhu);fflush(stdin);//------}p=p-next;}Save_income();if(Inhead!=NULL){charpanduan;printf(是否继续修改(Y/N));panduan=getchar();fflush(stdin);if(panduan=='Y'||panduan=='y'){xiugai_income();}}}voidriqi_xiugai_zhichu(){charxiugai[20];printf(请输入修改的日期);fflush(stdin);gets(xiugai);structlist*p=zhichuhead;while(p!=NULL){if(strcmp(p-info.riqi,xiugai)==0){fflush(stdin);printf(姓名:);gets(

1 / 27
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功