C语言实现家庭理财系统
作者:xingcheng--dp
这篇文章主要为大家详细介绍了C语言实现家庭理财系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了C语言实现家庭理财系统的具体代码,供大家参考,具体内容如下
比较简单
直接上代码:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include<time.h> #include<windows.h> int s=1; int b=1; struct Data { int a; char name[25]; char riqi[15]; float money; char beizhu[50]; }; struct list //链表申请 { struct Data info; struct list *next; }; struct list *Inhead = NULL; //收入链表头指针 struct list *Intail = NULL; //收入链表尾指针 struct list *zhichuhead = NULL; //支出链表头指针 struct list *zhichutail = NULL; //支出链表尾指针 struct list *temp = NULL; //定义一个全局空指针方便后面引用 int count=0; int count1=0; void inquire_income(); void inquire_pay(); void modify_income(); void modify_pay(); void time(); void inquire_menu(); void Add_income(); void Del_income(); void display_income(); void inquire_menu(); void full_name(); void money(); void content(); void modify_menu(); void full_name_modify_income(); void time_modify_income(); void money_modify_income(); void content_modify_income(); void Del_pay(); void inquire_pay(); void display_pay(); void modify_pay(); void Add_pay(); void full_name_pay(); void time_pay(); void money_pay(); void content_pay(); void full_name_modify_pay(); void time_modify_pay(); void money_modify_pay(); void content_modify_pay(); void all_income(); void all_pay(); void ALLfund(); void menu(); void Save_income() //将收入数据存入文件 { FILE *fp; fp=fopen("D:\\shouru.dat","wb"); struct list *p = Inhead; while (p != NULL) { fwrite(&p->info, sizeof(struct Data), 1, fp); //向文件写入内容 p = p->next; //指向下一个节点 } fclose(fp); //关闭文件 } void Save_zhichu() //将支出数据存入文件 { FILE *fp; fp = fopen("D:\\zhichu.dat","wb"); struct list *p = zhichuhead; while (p != NULL) { fwrite(&p->info, sizeof(struct Data), 1, fp); p = p->next; } fclose(fp); } void Open() //提前打开文件将已有的收入数据添加进来(如果没有直接跳过) { FILE *pp; pp = fopen("D:\\shouru.dat", "rb"); if(pp != NULL) { struct Data linshi; //申请一个结构体 while (fread(&linshi, sizeof(struct Data), 1, pp) == 1) //直到没有了为止 { temp = (struct list*)malloc(sizeof(struct list)); //分配空间赋给temp temp->info = linshi; //将linshi地址赋给temp指向 temp->next = NULL; //将指针指向空 if (Inhead == NULL) //分为两种情况一种为空的时候一种不为空 { Inhead = temp; Intail = temp; //因为第一个元素 } else { Intail->next = temp; //添加到前尾部的后指针 Intail = temp; //尾部指针 } } fclose(pp); } } void Openzhichu() //提前打开文件将已有的支出数据添加进来(如果没有直接跳过) { FILE *fp; fp = fopen("zhichu.dat","rb"); if (fp != NULL) { struct Data linshi; while (fread(&linshi, sizeof(struct Data), 1, fp) == 1) { temp = (struct list*)malloc(sizeof(struct list)); temp->info = linshi; temp->next = NULL; if (zhichuhead == NULL) { zhichuhead = temp; zhichutail = temp; } else { zhichutail->next = temp; zhichutail = temp; } ; } fclose(fp); } } /*********************************************************************/ void Menu() //菜单主界面 { system("cls"); //清屏 printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t *****************************************\n"); printf("\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 *\n"); printf("\n"); printf("\t\t\t\t *****************************************\n"); printf(" \n"); printf("\t\t\t\t 1:收入操作 \n"); printf("\t\t\t\t 2:支出操作 \n"); printf("\t\t\t\t 3:统计操作 \n"); printf("\t\t\t\t 0:退出 \n"); } void menu(){ system("cls"); //清屏 printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t *****************************************\n"); printf("\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 *\n"); printf("\n"); printf("\t\t\t\t *****************************************\n"); printf(" \n"); } /*****************************收入区**********************************/ void Income_menu() //收入界面 { system("cls"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t *****************************************\n"); printf(" \n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 * \n"); printf(" \n"); printf("\t\t\t\t *****************************************\n"); printf(" \n"); printf("\t\t\t\t 1.添加收入 \n"); printf("\t\t\t\t 2.删除收入 \n"); printf("\t\t\t\t 3.查询收入 \n"); printf("\t\t\t\t 4.显示收入 \n"); printf("\t\t\t\t 5.修改收入 \n"); printf("\t\t\t\t 0.返回上一级 \n"); } void Income() //进入收入界面 { int choice; while (1) { Income_menu(); //收入菜单显示 printf("\t\t\t\t 请输入选择: "); scanf("%d", &choice); fflush(stdin); //等待 if (choice == 0) { printf("\t\t\t\t 返回上一级中...... ");system("PAUSE");break; } else switch (choice) { case 1: Add_income(); Save_income(); break; //添加 case 2: Del_income(); Save_income(); break; //删除 case 3: inquire_income(); Save_income(); break; //查询 case 4: display_income(); Save_income(); break; //显示 case 5: modify_income(); Save_income(); break; //修改 } } } void Add_income() //添加收入 { char panduan; do { temp = (struct list*)malloc(sizeof(struct list)); if(Inhead == NULL){ s=1; } else{ s=Intail->info.a+1; } temp->info.a=s; printf("\t\t\t\t 姓名: "); gets(temp->info.name); fflush(stdin); printf("\t\t\t\t 日期( XX 年 XX 月 XX 日): "); gets(temp->info.riqi); fflush(stdin); printf("\t\t\t\t 收入: "); scanf("%f", &temp->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(temp->info.beizhu); fflush(stdin); printf("\n"); temp->next = NULL; //将尾部变为空 if (Inhead == NULL) { Inhead = temp; Intail = temp; } else { Intail->next = temp; Intail = temp; } Save_income(); do{ printf("\t\t\t\t 是否 (Y/N) 继续添加信息:"); panduan = getchar(); fflush(stdin); if(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N') {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } while (panduan == 'Y' || panduan == 'y'); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } void Del_income() //删除收入 { char shanchu[20],panduan2; int t=0; struct list *p = NULL; struct list *m = NULL; struct list *n = NULL; p = Inhead; if(p==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ part: if(t==0) printf("\t\t\t\t 请输入删除姓名: "); else { printf("\t\t\t\t 请重新输入删除姓名: "); } gets(shanchu); if (strcmp(Inhead->info.name, shanchu) == 0) { count++; while (Inhead != NULL && strcmp(Inhead->info.name, shanchu) == 0) { char ch; printf("\t\t\t\t 编号: "); printf("%d\n",Inhead->info.a); printf("\t\t\t\t 姓名: "); puts(Inhead->info.name); printf("\t\t\t\t 日期: "); puts(Inhead->info.riqi); printf("\t\t\t\t 收入: "); printf("%.3f\n", Inhead->info.money); printf("\t\t\t\t 备注: "); puts(Inhead->info.beizhu); printf("\t\t\t\t 找到一个数据名字为%s,确认删除 Y/N ?", shanchu); ch = getchar(); fflush(stdin); if (ch == 'y' || ch == 'Y'){ Inhead = Inhead->next; p = Inhead; while(p!=NULL){ p->info.a=p->info.a-1; p=p->next; } } else { break; } } } else { if (strcmp(Intail->info.name, shanchu) == 0) { count++; do { m = p; p = p->next; } while (p != Intail); char ch2; printf("\t\t\t\t 编号: "); printf("%d\n",Intail->info.a); printf("\t\t\t\t 姓名: "); puts(Intail->info.name); printf("\t\t\t\t 日期: "); puts(Intail->info.riqi); printf("\t\t\t\t 收入: "); printf("%.4f\n", Intail->info.money); printf("\t\t\t\t 备注: "); puts(Intail->info.beizhu); printf("\t\t\t\t 找到一个数据名字为%s,确认删除 Y/N ?", shanchu); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ m->next = NULL; Intail=m; } } else { while( count>=3 && p->next != NULL && strcmp(p->info.name, shanchu) != 0 ) { m = p; p = p->next; n = p->next; } if(count>=3 && strcmp(p->info.name, shanchu) == 0) { char ch3; printf("\t\t\t\t 编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 收入: "); printf("%.3f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据名字为%s,确认删除 Y/N ?", shanchu); ch3 = getchar(); fflush(stdin); if (ch3 == 'y' || ch3 == 'Y') m->next = n; while(n!=NULL){ n->info.a=n->info.a-1; n=n->next; } } else { printf("\t\t\t\t\t 不存在\n"); if(t==0){ t=1; goto part; } } } } Save_income(); if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续删除 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { Del_income();break; } else if(panduan=='n'||panduan=='N'){ break; } else {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } } void inquire_income() //查询收入 { inquire_menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); fflush(stdin); switch (choice) { case 1: full_name(); break; case 2: time(); break; case 3: money(); break; case 4: content(); break; default: printf("\t\t\t\t 输入错误 "); break; } } void full_name() //通过名字查询收入 { char chazhao[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的名字: "); gets(chazhao); struct list *p = Inhead; while (p != NULL) { if (strcmp(p->info.name, chazhao) == 0) //循环遍历链表 { printf("\t\t\t\t 编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 收入: "); printf("%.3f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; //到下一个节点的头 } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do { printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); //清空输入缓冲区,为了确保不影响后面的数据读取 if (panduan == 'Y' || panduan == 'y') { full_name();break; } else if(panduan=='n'||panduan=='N'){ inquire_income(); break; } else {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } } void time() //通过日期查询收入 { char chazhao[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的日期: "); gets(chazhao); struct list *p = Inhead; while (p != NULL) { if (strcmp(p->info.riqi, chazhao) == 0) { printf("\t\t\t\t 编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do { printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { time() ; break; } else if(panduan=='n'||panduan=='N'){inquire_income();break; } else {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }} } void money() //通过金额查询收入 { float chazhao; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的金额:"); scanf("%f", &chazhao); fflush(stdin); struct list *p = Inhead; while (p != NULL) { if (p->info.money == chazhao) { printf("\t\t\t\t 编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { money(); break; } else if(panduan=='n'||panduan=='N'){ inquire_income(); break; } else {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } } void content() //通过备注查询收入 { char chazhao[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的备注:"); gets(chazhao); struct list* p = Inhead; while (p != NULL) { if (strcmp(p->info.beizhu, chazhao) == 0) { printf("\t\t\t\t 编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { content();break; } else if(panduan=='n'||panduan=='N'){inquire_income(); break;} else{printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void display_income() //显示所有收入不包括支出 { if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ struct list* p = Inhead; while (p != NULL) { printf("\t\t\t\t==·==·==·==·==·==\n"); printf("\t\t\t\t| 编号: "); printf("%12d|\n",p->info.a); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 姓名: "); printf("%12s|\n",p->info.name); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 日期: "); printf("%12s|\n",p->info.riqi); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 收入: "); printf("%12.4f|\n", p->info.money); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 备注: "); printf("%12s|\n",p->info.beizhu); p = p->next; } system("PAUSE"); }} void modify_income() //修改收入控制台 { modify_menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); fflush(stdin); switch (choice) { case 1: full_name_modify_income(); break; case 2: time_modify_income(); break; case 3: money_modify_income(); break; case 4: content_modify_income(); break; default: printf("\t\t\t\t 输入错误 "); break; } } void full_name_modify_income() //通过名字修改收入 { char xiugai[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的名字: "); fflush(stdin); gets(xiugai); struct list *p = Inhead; while (p != NULL) { if (strcmp(p->info.name, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据名字为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 收入: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_income(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { full_name_modify_income();break; } else if(panduan=='n'||panduan=='N'){modify_income(); break;} else{printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE");} }} void time_modify_income() //通过日期修改收入 { char xiugai[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的日期: "); fflush(stdin); gets(xiugai); struct list *p = Inhead; while (p != NULL) { if (strcmp(p->info.riqi, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据日期为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 收入: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_income(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { time_modify_income();break; } else if(panduan=='n'||panduan=='N'){modify_income(); break;} else{printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE");} }} void money_modify_income() //通过金额修改收入 { float xiugai; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 空列表!!!\n"); printf("\t\t\t\t 请返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的金额:"); scanf("%f", &xiugai); fflush(stdin); struct list *p = Inhead; while (p != NULL) { if (p->info.money == xiugai) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据金额为%f,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 收入: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_income(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { money_modify_income();break; } else if(panduan=='n'||panduan=='N'){modify_income(); break;} else{printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE");} }} void content_modify_income() //通过备注修改收入 { char xiugai[20]; int j=0; if(Inhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的备注: "); fflush(stdin); gets(xiugai); struct list* p = Inhead; while (p != NULL) { if (strcmp(p->info.beizhu, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据备注为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 收入: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现收入: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_income(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (Inhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { content_modify_income();break; } else if(panduan=='n'||panduan=='N'){modify_income(); break;} else{printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE");} }} /*********************************支出区******************************************/ void zhichu_menu() //支出界面 { system("cls"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t ****************************\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 * \n"); printf("\t\t\t\t ****************************\n"); printf(" \n"); printf("\t\t\t\t 1.添加支出 \n"); printf("\t\t\t\t 2.删除支出 \n"); printf("\t\t\t\t 3.查询支出 \n"); printf("\t\t\t\t 4.显示支出 \n"); printf("\t\t\t\t 5.修改支出 \n"); printf("\t\t\t\t 0.返回上一级 \n"); } void zhichu() //支出界面运行 { int choice; while (1) { zhichu_menu(); printf("\t\t\t\t 请输入选择: "); scanf("%d", &choice); fflush(stdin); if (choice == 0) { printf("\t\t\t\t 返回上一级中...... ");system("PAUSE");break; } else switch (choice) { case 1: Add_pay(); Save_zhichu(); break; case 2: Del_pay(); Save_zhichu(); break; case 3: inquire_pay(); Save_zhichu(); break; case 4: display_pay(); Save_zhichu(); break; case 5: modify_pay(); Save_zhichu(); break; } } } void Add_pay() //添加支出 { char panduan; do { if(zhichuhead == NULL){ b=1; } else{ b=zhichutail->info.a+1; } temp = (struct list*)malloc(sizeof(struct list)); temp->info.a=b; printf("\t\t\t\t 姓名: "); gets(temp->info.name); fflush(stdin); printf("\t\t\t\t 日期( XX 年 XX 月 XX 日): "); gets(temp->info.riqi); fflush(stdin); printf("\t\t\t\t 支出: "); scanf("%f", &temp->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(temp->info.beizhu); fflush(stdin); printf("\n"); temp->next = NULL; if (zhichuhead == NULL) { zhichuhead = temp; zhichutail = temp; } else { zhichutail->next = temp; zhichutail = temp; } Save_zhichu(); do{ printf("\t\t\t\t 是否 (Y/N) 继续添加信息 "); panduan = getchar(); fflush(stdin); if(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N') {printf("\t\t\t\t 输入错误!\n");} }while(panduan != 'Y'&& panduan != 'y'&&panduan != 'n' && panduan != 'N'); } while (panduan == 'Y' || panduan == 'y'); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } void Del_pay() //删除支出 { int t=1; char shanchu[20]; struct list *p = NULL; struct list *m = NULL; struct list *n = NULL; p = zhichuhead; if(p==NULL) { printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ place : if(t) printf("\t\t\t\t 请输入删除姓名: "); else { printf("\n\t\t\t\t 请重新输入删除姓名: "); } gets(shanchu); if (strcmp(zhichuhead->info.name, shanchu) == 0) { count1++; while (zhichuhead != NULL && strcmp(zhichuhead->info.name, shanchu) == 0) { char ch; printf("\t\t\t\t 编号: ");printf("%d\n",zhichuhead->info.a); printf("\t\t\t\t 姓名: "); puts(zhichuhead->info.name); printf("\t\t\t\t 日期: "); puts(zhichuhead->info.riqi); printf("\t\t\t\t 支出: "); printf("%.3f\n", zhichuhead->info.money); printf("\t\t\t\t 备注: "); puts(zhichuhead->info.beizhu); printf("\t\t\t\t 找到一个数据名字为 %s,确认删除 Y/N ?", shanchu); ch = getchar(); fflush(stdin); if (ch == 'y' || ch == 'Y') { zhichuhead = zhichuhead->next; p = zhichuhead; while(p!=NULL){ p->info.a=p->info.a-1; p=p->next; } } else{ break;} } } else { if (strcmp(zhichutail->info.name, shanchu) == 0) { count1++; do { m = p; p = p->next; } while (p != zhichutail); char ch2; printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.3f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据名字为 %s,确认删除 Y/N ?", shanchu); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y') { m->next = NULL; zhichutail=m; } } else{ while (count1>=3 && strcmp(p->info.name, shanchu) != 0 && n->next != NULL) { m = p; p = p->next; n = p->next; } if (count1>=3 && strcmp(p->info.name, shanchu) == 0){ char ch3; printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.3f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据名字为 %s,确认删除 Y/N ?", shanchu); ch3 = getchar(); fflush(stdin); if (ch3 == 'y' || ch3 == 'Y') { m->next =n; while(n!=NULL){ n->info.a=n->info.a-1; n=n->next; } } } else{ printf("\t\t\t\t\t不存在"); if(t==1){ t=0; goto place;} } } } Save_zhichu(); if (zhichuhead != NULL){ char panduan; do{ printf("\t\t\t\t 是否继续删除 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { Del_pay();break; } else if(panduan =='n'||panduan == 'N' ){ break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } } void inquire_pay() //查询支出 { inquire_menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); fflush(stdin); switch (choice) { case 1: full_name_pay(); break; case 2: time_pay(); break; case 3: money_pay(); break; case 4: content_pay(); break; default: printf("\t\t\t\t 输入错误 "); break; } } void full_name_pay() //通过名字查询支出 { char chazhao[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的名字: "); gets(chazhao); struct list *p = zhichuhead; while (p != NULL) { if (strcmp(p->info.name, chazhao) == 0) { printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.3f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { full_name_pay();break; } else if(panduan =='n'||panduan == 'N' ){ inquire_pay(); break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } }} void time_pay() //通过日期查询支出 { char chazhao[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); } else{ printf("\t\t\t\t 请输入查询的日期: "); gets(chazhao); struct list* p = zhichuhead; while (p != NULL) { if (strcmp(p->info.riqi, chazhao) == 0) { printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { time_pay();break; } else if(panduan =='n'||panduan == 'N' ){ inquire_pay(); break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void money_pay() //通过金额查询支出 { float chazhao; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的金额:"); scanf("%f", &chazhao); fflush(stdin); struct list* p = zhichuhead; while (p != NULL) { if (p->info.money == chazhao) { printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { money_pay();break; } else if(panduan =='n'||panduan == 'N' ){ inquire_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void content_pay() //通过备注查询支出 { char chazhao[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入查询的备注: "); gets(chazhao); struct list* p = zhichuhead; while (p != NULL) { if (strcmp(p->info.beizhu, chazhao) == 0) { printf("\t\t\t\t 编号: ");printf("%d\n",p->info.a); printf("\t\t\t\t 姓名: "); puts(p->info.name); printf("\t\t\t\t 日期: "); puts(p->info.riqi); printf("\t\t\t\t 支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 备注: "); puts(p->info.beizhu); j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续查询 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { content_pay(); } else if(panduan =='n'||panduan == 'N' ){ inquire_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void display_pay() //显示所有人支出 { if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ struct list* p = zhichuhead; while (p != NULL) { fflush(stdin); printf("\t\t\t\t==·==·==·==·==·==\n"); printf("\t\t\t\t| 编号: ");printf("%12d|\n",p->info.a); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 姓名: ");printf("%12s|\n",p->info.name); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 日期: ");printf("%12s|\n",p->info.riqi); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 支出: ");printf("%12.4f\n", p->info.money); printf("\t\t\t\t--------------------\n"); printf("\t\t\t\t| 备注: ");printf("%12s|\n",p->info.beizhu); p = p->next; } system("PAUSE"); }} void modify_pay() //修改支出控制台 { modify_menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); fflush(stdin); switch (choice) { case 1: full_name_modify_pay(); break; case 2: time_modify_pay(); break; case 3: money_modify_pay(); break; case 4: content_modify_pay(); break; default: printf("\t\t\t\t 输入错误 "); break; } } void full_name_modify_pay() //通过名字修改支出 { char xiugai[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的名字: "); fflush(stdin); gets(xiugai); struct list *p = zhichuhead; while (p != NULL) { if (strcmp(p->info.name, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据名字为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 支出: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } if(j==0){ printf("\t\t\t\t 不存在\n "); } Save_zhichu(); if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { full_name_modify_pay();break; } else if(panduan =='n'||panduan == 'N' ){ modify_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void time_modify_pay() //通过日期修改支出 { char xiugai[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 空列表!!!\n"); printf("\t\t\t\t 请返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的日期: "); fflush(stdin); gets(xiugai); struct list *p = zhichuhead; while (p != NULL) { if (strcmp(p->info.riqi, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据日期为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 支出: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_zhichu(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { time_modify_pay();break; } else if(panduan =='n'||panduan == 'N' ){ modify_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void money_modify_pay() //通过金额修改支出 { float xiugai; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的金额:"); scanf("%f", &xiugai); fflush(stdin); struct list* p = zhichuhead; while (p != NULL) { if (p->info.money == xiugai) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据金额为%f,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 支出: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_zhichu(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { money_modify_pay();break; } else if(panduan =='n'||panduan == 'N' ){ modify_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} void content_modify_pay() //通过备注修改支出 { char xiugai[20]; int j=0; if(zhichuhead==NULL){ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } else{ printf("\t\t\t\t 请输入修改的备注: "); fflush(stdin); gets(xiugai); fflush(stdin); struct list *p = zhichuhead; while (p != NULL) { if (strcmp(p->info.beizhu, xiugai) == 0) { char ch2; fflush(stdin); printf("\n\t\t\t\t 原编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 原姓名: "); puts(p->info.name); printf("\t\t\t\t 原日期: "); puts(p->info.riqi); printf("\t\t\t\t 原支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 原备注: "); puts(p->info.beizhu); printf("\t\t\t\t 找到一个数据备注为%s,确认修改 Y/N ?", xiugai); ch2 = getchar(); fflush(stdin); if (ch2 == 'y' || ch2 == 'Y'){ printf("\t\t\t\t 姓名: "); gets(p->info.name); fflush(stdin); printf("\t\t\t\t 日期: "); gets(p->info.riqi); fflush(stdin); printf("\t\t\t\t 支出: "); scanf("%f", &p->info.money); fflush(stdin); printf("\t\t\t\t 备注: "); gets(p->info.beizhu); fflush(stdin); printf("\n\t\t\t\t 现编号: "); printf("%d\n",p->info.a); printf("\t\t\t\t 现姓名: "); puts(p->info.name); printf("\t\t\t\t 现日期: "); puts(p->info.riqi); printf("\t\t\t\t 现支出: "); printf("%.4f\n", p->info.money); printf("\t\t\t\t 现备注: "); puts(p->info.beizhu);} j=1; } p = p->next; } Save_zhichu(); if(j==0){ printf("\t\t\t\t 不存在\n "); } if (zhichuhead != NULL) { char panduan; do{ printf("\t\t\t\t 是否继续修改 (Y/N):"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { content_modify_pay();break; } else if(panduan =='n'||panduan == 'N' ){ modify_pay();break; } else{printf("\t\t\t\t 输入错误!\n");} }while(panduan !='Y'&& panduan != 'y'&&panduan != 'n'&& panduan != 'N'); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回支出操作界面进行添加!!!!!\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); }}} /*******************************--------********************************/ void inquire_menu() //查询界面 { system("cls"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t ****************************\n"); printf("\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 * \n"); printf("\n"); printf("\t\t\t\t ****************************\n"); printf(" \n"); printf("\t\t\t\t 1.按名字查询 \n"); printf("\t\t\t\t 2.按日期查询 \n"); printf("\t\t\t\t 3.按金额查询 \n"); printf("\t\t\t\t 4.按备注查询 \n"); printf("\t\t\t\t 0.返回上一级 \n"); } /*******************************--------********************************/ void modify_menu() //修改界面 { system("cls"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t ***************************************\n"); printf("\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 * \n"); printf("\n"); printf("\t\t\t\t ***************************************\n"); printf(" \n"); printf("\t\t\t\t 1.按名字修改 \n"); printf("\t\t\t\t 2.按日期修改 \n"); printf("\t\t\t\t 3.按金额修改 \n"); printf("\t\t\t\t 4.按备注修改 \n"); printf("\t\t\t\t 0.返回上一级 \n"); } /****************************-----统计区-------************************/ void tongji_menu() { system("cls"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\t\t\t\t ***************************************\n"); printf("\n"); printf("\t\t\t\t * 欢迎使用家庭财务管理系统 * \n"); printf("\n"); printf("\t\t\t\t ***************************************\n"); printf(" \n"); printf("\t\t\t\t 1.总收入 \n"); printf("\t\t\t\t 2.总支出 \n"); printf("\t\t\t\t 3.总资金 \n"); printf("\t\t\t\t 0.返回上一级 \n"); } void Tongji() //统计控制台 { while (1) { tongji_menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); if (choice == 0) { printf("\t\t\t\t 返回上一级中...... ");system("PAUSE");break; } switch (choice) { case 1: all_income(); break; case 2: all_pay(); break; case 3: ALLfund(); break; default: printf("\t\t\t\t 输入错误 "); break; } } } void all_income() //总收入 { float shouru = 0; struct list *linshi; linshi = Inhead; if (linshi != NULL) { do { shouru = linshi->info.money + shouru; linshi = linshi->next; } while (linshi != NULL); printf("\t\t\t\t总收入为:%.4f", shouru); system("PAUSE"); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将前往收入操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } void all_pay() //总支出 { float zhichu = 0; struct list *linshi; linshi = zhichuhead; if (linshi != NULL) { do { zhichu = linshi->info.money + zhichu; linshi = linshi->next; } while (linshi != NULL); printf("\t\t\t\t总支出为:%.4f", zhichu); system("PAUSE"); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将前往支出操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE"); } } void ALLfund() //总的资金 { float zhichu = 0; float zongzijin; struct list *linshi; linshi = zhichuhead; if (linshi != NULL) { do { zhichu = linshi->info.money + zhichu; linshi = linshi->next; } while (linshi != NULL); } float shouru = 0; linshi = Inhead; if (linshi != NULL) { do { shouru = linshi->info.money + shouru; linshi = linshi->next; } while (linshi != NULL); printf("\t\t\t\t剩余的资金为:%.4f", shouru - zhichu); system("PAUSE"); } else{ printf("\t\t\t\t 目前为空列表!\n"); printf("\t\t\t\t 即将返回操作界面进行添加\n"); printf("\t\t\t\t 正在返回......"); system("PAUSE");} } /*******************************************************************/ void Quit()//退出 { char panduan; printf("\t\t\t\t 确认退出 (Y/N)"); panduan = getchar(); fflush(stdin); if (panduan == 'Y' || panduan == 'y') { printf("\t\t\t\t 正在退出中...... "); system("PAUSE"); exit(0); } } int main() { system("color E1"); int t=0,mm,nn; char *user; char *pass; char username[30]={0},pass_word[30]={0},password; int count=0; printf("\n\n\n\n\n\n\n"); //密码显示为 * do{ count = 0; if(t) { if(mm==0&&nn!=0){ printf("\n\t\t\t\t \t 密码错误!!! "); } else if(mm!=0&&nn==0) { printf("\n\t\t\t\t \t 账号错误!!! "); } else{ printf("\n\t\t\t\t \t 账号或密码错误!!! "); } system("PAUSE"); t=0; } menu(); printf("\t\t\t\t\t 账号:"); fgets(username,30,stdin); fflush(stdin); printf("\t\t\t\t\t 密码:"); while (password=getch()) { if(password == '\r') //Enter { pass_word[count]='\0'; break; } else if((password=='\b') && (count>0)) //Backspace { printf("\b \b"); count--; } else if((count==0) && (password=='\b')) ; else { pass_word[count] = password; count++; printf("*"); } } pass=pass_word; t=strcmp(username,"root\n") || strcmp(pass,"root"); mm=strcmp(username,"root\n"); nn=strcmp(pass,"root"); }while(t); Open(); Openzhichu(); while (1) { Menu(); int choice; printf("\t\t\t\t 请输入你的选择: "); scanf("%d", &choice); fflush(stdin); switch (choice) { case 1: Income(); break; case 2: zhichu(); break; case 3: Tongji(); break; case 0: Quit(); break; default: printf("\t\t\t\t 输入错误 "); break; } } return 0; }
部分运行结果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。