您好,欢迎访问三七文档
#includestdio.h#includestdlib.h#includestring.h#includeconio.h#includetime.h#defineMAXNAME11//¼ÒÍ¥³ÉÔ±ÐÕÃûµÄ×î´ó³¤¶È#defineMAXDETAIL21//×¢×î´ó³¤¶È#defineMENU_COUNT11//²Ëµ¥Ñ¡Ïî¸öÊýtypedefstructfi_info{intyear;intmonth;intday;intfi_type;charname[MAXNAME];floatmoney;chardetail[MAXDETAIL];structfi_info*next;};structmima{charID1[10];charsecret1[10];charquestion1[40];charanswer1[40];charquestion2[40];charanswer2[40];structmima*next;};mima*head2=NULL;voidenrol();mima*m=NULL;fi_info*head=NULL;fi_info*head1=NULL;intcount=0,count1=0,count2=0,c=0;charb1[20];charb2[30];voidmima1();voidreacher();voidinitialize();voidadd_income();voidshow();voidsearch_income();voiddelete_income();voidupdate_income();voidadd_payout();voidsearch_payout();voiddelete_payout();voidupdate_payout();voidcount_total();voidrecover();voidrestore();voidother();voidrestore1();voidrestore2();voidquit();voidsave_to_file();voidsave();/*ÐÞ¸ÄÃÜÂë*/voidcolor();/*ÐÞ¸ÄÑÕÉ«*/intmain(){intselected=0;mima1();initialize();restore1();while(selected=0&&selected=MENU_COUNT){system(cls);printf(******************************************************************************\n);printf(******************************************************************************\n);printf(*****»¶Ó½øÈë¼ÒÍ¥²ÆÎñ¹ÜÀíϵͳ*****\n);printf(*****1.Ìí¼ÓÊÕÈë´¦Àí*****\n);printf(*****2.²éѯÊÕÈëÃ÷ϸ´¦Àí*****\n);printf(*****3.ɾ³ýÊÕÈë´¦Àí*****\n);printf(*****4.ÐÞ¸ÄÊÕÈë´¦Àí*****\n);printf(*****5.Ìí¼ÓÖ§³ö´¦Àí*****\n);printf(*****6.²éѯ֧³öÃ÷ϸ´¦Àí*****\n);printf(*****7.ɾ³ýÖ§³ö´¦Àí*****\n);printf(*****8.ÐÞ¸ÄÖ§³ö´¦Àí*****\n);printf(*****9.ͳ¼Æµ±Ç°½áÓà*****\n);printf(*****10.ÏÔʾ¿ªÖ§*****\n);printf(*****11:ÆäËû¹¦ÄÜ*****\n);printf(*****0.Í˳ö*****\n);printf(******************************************************************************\n);printf(******************************************************************************\n);printf(ÇëÑ¡ÔñÒª½øÐеIJÙ×÷(%d-%d):,0,MENU_COUNT);if(scanf(%d,&selected)!=1||selected0||selectedMENU_COUNT){printf(ÊäÈëÓÐÎó!ÇëÑ¡Ôñ(%d-%d)Ö®¼äµÄÊý×Ö!°´ÈÎÒâ¼üÖØÊÔ...,0,MENU_COUNT);fflush(stdin);getchar();}else{switch(selected){case1:add_income();break;case2:search_income();break;case3:delete_income();break;case4:update_income();break;case5:add_payout();break;case6:search_payout();break;case7:delete_payout();break;case8:update_payout();break;case9:count_total();break;case10:show();break;case11:other();break;case0:quit();}}selected=0;}return0;}voidother(){system(cls);inta=0;printf(*****1:ÐÞ¸ÄÓû§ÃûºÍÃÜÂë*****\n);printf(*****2:ÐÞ¸ÄÑÕÉ«*****\n);printf(*****3:»ØÊÕÏä*****\n);printf(ÇëÊäÈëÄãµÄÑ¡Ôñ£º\t);scanf(%d,&a);if(a4)switch(a){case1:save();break;case2:color();break;case3:recover();break;}elseprintf(ÊäÈë´íÎó£¡);}voidenrol(){system(cls);charID[10];inti;printf(ÊäÈë×¢²áµÄÓû§Ãû£º\t);scanf(%s,ID);for(i=0;icount2;i++){if(strcmp(ID,m-ID1)==0){printf(ÊäÈëµÄÓû§ÃûÒÑ´æÔÚ£¡\n);system(PAUSE);enrol();}}m=head2;m=(mima*)malloc(sizeof(mima));printf(ÊäÈë×¢²áµÄÃÜÂ룺\t);scanf(%s,m-secret1);printf(ÒÔÏÂÎÊÌâ±ãÓÚÄãµÄÃÜÂëÕһأ¬Çë½÷¼Ç£¡\n);printf(ÊäÈëÄãµÄµÚÒ»¸öÎÊÌ⣺\t);scanf(%s,m-question1);printf(ÇëÊäÈëµÄÄãµÄÎÊÌâ´ð°¸£º\t);scanf(%s,m-answer1);printf(ÊäÈëÄãµÄµÚ¶þ¸öÎÊÌ⣺\t);scanf(%s,m-question2);printf(ÇëÊäÈëµÄÄãµÄÎÊÌâ´ð°¸£º\t);scanf(%s,m-answer2);strcpy(m-ID1,ID);m-next=head2;head2=m;count2=count2+1;printf(×¢²á³É¹¦£¡\n);system(PAUSE);}voidreacher(){mima*m=NULL;charID[10],answer1[40],answer2[40];inta=0;printf(ÇëÊäÈëÄãµÄÓû§Ãû£º\t);scanf(%s,ID);for(m=head2;m!=NULL;m=m-next){if(strcmp(ID,m-ID1)==0){a=a+1;break;}}if(a==0){printf(ÊäÈëµÄÓû§²»´æÔÚ£¡\n);exit(0);}else{printf(ÎÊÌâÒ»£º%s\n,m-question1);printf(´ð°¸£º\t);scanf(%s,answer1);printf(ÎÊÌâ¶þ£º%s\n,m-question2);printf(´ð°¸£º\t);scanf(%s,answer2);if(strcmp(answer1,m-answer1)==0&&strcmp(answer2,m-answer2)==0)printf(ÄãµÄÃÜÂëΪ:%s,m-secret1);else{printf(»Ø´ð´íÎó£¡\n);exit(0);}}}voidmima1(){intb=0,d=0;FILE*fb;inti;if((fb=fopen(mima1.txt,r))==NULL){fopen(mima1.txt,w);}fscanf(fb,%d,&count2);for(i=0;icount2;i++){m=(mima*)malloc(sizeof(mima));fscanf(fb,%s,m-ID1);fscanf(fb,%s,m-secret1);fscanf(fb,%s,m-question1);fscanf(fb,%s,m-answer1);fscanf(fb,%s,m-question2);fscanf(fb,%s,m-answer2);m-next=NULL;if(head2==NULL)head2=m;else{m-next=head2;head2=m;}}fclose(fb);printf(×¢²áÇëÊäÈë1£¬·ñÔòÈÎÒâÊäÈëÆäËûÊý£º\t);scanf(%d,&b);if(b==1)enrol();printf(ÕÒ»ØÃÜÂëÇëÊäÈë1£¬·ñÔòÈÎÒâÊäÈëÆäËûÊý£º\t);scanf(%d,&d);if(d==1)reacher();charID[10],secret[10];printf(\n);printf(\n);printf(\n);printf(µÇ½£º\n);printf(ÇëÊäÈëÓû§Ãû£º\t);scanf(%s,ID);printf(ÇëÊäÈëÃÜÂ룺\t);scanf(%s,secret);for(m=head2;m!=NULL;m=m-next){if(strcmp(ID,m-ID1)==0&&strcmp(secret,m-secret1)==0){break;}}if(m==NULL){system(cls);printf(ÊäÈë´íÎó£¬ÇëÖØÐÂÊäÈ룡\n);c=c+1;if(c3){printf(»¹ÓÐ%dÊäÈë»ú»á£¡\n,3-c);mima1();}elseexit(0);}}voidinitialize(){FILE*fp=NULL;fi_info*p=NULL;inti;chara[5]=.txt;strcpy(b1,m-ID1);strcat(b1,a);if((fp=fopen(b1,r))==NULL){fopen(b1,w);}p=head;fscanf(fp,%d,&count);for(i=0;icount;i++){p=(fi_info*)malloc(sizeof(fi_info));fscanf(fp,%d,&p-year);fscanf(fp,%d,&p-month);fscan
本文标题:C语言家庭财务管理
链接地址:https://www.777doc.com/doc-6239300 .html