我写的一个理财系统,有很多BUG,只写了大部份,请大家帮我完善和纠正!
程序代码:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <conio.h> #include <dos.h> #define N 12 #include <stdio.h> #include <conio.h> static char zhanghao[N],mimao[N],Mimao[N]; static number=0; /*菜单*/ void Menu() { int i; textattr(109+(BLACK<<3)+(WHITE<<5)); clrscr(); gotoxy(10,1); cputs("| ------- welcome to you useing it------------------|"); gotoxy(10,2); cputs("| -------please you choice adata to choice----------|"); gotoxy(10,3); cputs("| -------- -----1. 注册 ----------------------------|"); gotoxy(10,4); cputs("| -------- -----2. 登录 ----------------------------|"); gotoxy(10,5); cputs("| ------------- 3. 设置 ---------------------------|"); gotoxy(10,6); cputs("| --------------4. 收支 ---------------------------|"); gotoxy(10,7); cputs("| --------------5. 报表 ---------------------------|"); gotoxy(10,8); cputs("| --------------6. 银行 ---------------------------|"); gotoxy(10,9); cputs("|---------------7.EXIT ----------------------------|"); gotoxy(1,12); } /*注册账号*/ void Register() { int i=0;int j=0;int n=0,len; char ch; printf("\t\t\t\t请按照提示申请账号!\n\n"); printf("请输入新的账号:"); while((zhanghao[n++]=getchar())=='r') break; printf("请输入密码:"); for(ch=getch();ch!=13;ch=getch()) { if(j>=N) break; if(ch=='\b') { if(j>0) { printf("\b"); mimao[--j]='\0'; } putchar(0); printf("\b"); continue; } printf("*"); mimao[j++]=ch; } mimao[j]='\0'; printf("\n请再一次确认密码:"); for(ch=getch();ch!=13;ch=getch()) { if(i>=N) break; if(ch=='\b') { if(i>0) { printf("\b"); Mimao[--i]='\0'; } putchar(0); printf("\b"); continue; } printf("*"); Mimao[i++]=ch; } Mimao[i]='\0'; printf("你已经成功申请\n" ); /*这里还没有学会怎么弄看两次输入的密码一样*/ } /*登录账号*/ void record() { char _mimao[N];char _zhanghao[N]; int i=0;int j=0;int n=0,len; char ch; printf("账号:"); while((_zhanghao[n++]=getchar())=='r') break; printf("请输入密码:"); for(ch=getch();ch!=13;ch=getch()) { if(j>=N) break; if(ch=='\b') { if(j>0) { printf("\b"); _mimao[--j]='\0'; } putchar(0); printf("\b"); continue; } printf("*"); _mimao[j++]=ch; } _mimao[j]='\0'; for(i=0;i<N;i++) { if((mimao[i]==_mimao[i])&&(zhanghao[i]==_zhanghao[i])) continue; else printf("你的账号或者密码有误,请重新输入"); } } /*日期结构*/ struct Date { char year[5]; char month[3]; char day1[3]; }; /*消费结构*/ struct Daycost { char name[20]; int num; float price; float count; struct Date day; struct Daycost *next; }; /*消费情况链表*/ struct Daycost *Day_cost() { struct Daycost *p=(struct Daycost*)malloc(sizeof(struct Daycost)); printf("商品名字:"); gets(p->name); printf("商品数量:"); scanf("%d",&p->num); printf("请输入商品价格\n"); scanf("%f",&p->price); printf("请输入年份(四位)\n"); getchar(); gets(p->day.year); while(sizeof(p->day.year)>5) { printf("输入的格式错误请在输入:"); gets(p->day.year); } printf("请输入月份:"); gets(p->day.month); while(strlen(p->day.month)>3) { printf("输入的格式错误请在输入:"); gets(p->day.month); } printf("请输入日子:"); gets(p->day.day1); while(sizeof(p->day.day1)>3) { printf("输入的格式错误请在输入:"); gets(p->day.day1); } p->count=(p->num)*(p->price); return p; } /*创建一个日期*/ struct Date *day() { struct Date *q=(struct Date*)malloc(sizeof(struct Date)); printf("请输入年份\n"); scanf("%s",&q->year); while(sizeof(q->year)>5) { printf("输入格式不正确,请重新输入\n"); gets(q->year); } printf("请输入月份\n"); gets(q->month); while(sizeof(q->month)>3) { printf("输入格式不正确,请重新输入\n"); } printf("请输入日子\n"); gets(q->day1); while(sizeof(q->day1)>3) { printf("输入格式不正确,请重新输入\n"); gets(q->day1); } return q; } /*读取消费情况*/ void display(struct Daycost *q) { struct Daycost *p=q; if(p==NULL) { printf("没有消费\n"); } else { printf("\t年\t月\t日\t名字\t数量\t价格\t总价\n"); while(p!=NULL) { printf("\t%s",p->day.year); printf("\t%s",p->day.month); printf("\t%s",p->day.day1); printf("\t%s",p->name); printf("\t%d",p->num); printf("\t%2.2f",p->price); printf("\t%f\n",p->count); p=p->next; } } } /*消费情况的录入记录*/ struct Daycost *total_day() { int flag=1; char i; struct Daycost *head=NULL,*p; while(flag) { printf("请选择:1:输入\t2:结束\n"); i=getche(); clrscr(); if(i=='1') { if(head==NULL) { p=Day_cost(); head=p; number++; } else { p=Day_cost(); p->next=head; head=p; number++; } flag=1; } if(i=='2') { flag=0; } } return head; } /*个人收支情况*/ void shouzhi() { char choice; struct Daycost *p; struct Date *q; int n=1; float sum; while(n) { clrscr(); printf("\t\t\t1:数据的录入\n\n"); printf("\t\t\t2:查找某天的消费情况\n\n"); printf("\t\t\t3:查看在记录天数中总的消费金额\n\n"); printf("\t\t\t4:写入文件\n\n"); printf("\t\t\t5:从文件中读写\n\n"); printf("\t\t\t6:退出\n"); printf("\n\t\t\t请在1~6之间选择\n"); choice=getche(); clrscr(); switch(choice) { case'1':p=total_day(); display(p); system("pause");break; case'2':q=day(); break; case'6':n=0; break; } } } /*主函数*/ void main(void) { int n=1; while(n) { char choice; Menu(); choice=getche(); clrscr(); switch(choice) { case '1' :Register();system("pause");break; case '2' :record(); system("pause");break; case '4' :shouzhi(); system("pause");break; case '7' :n=0; break; default :printf("error please again input"); } } }密码问题我不会弄,还有就是单键表问题,为什么我读入数据了,读不出来(部份),真的是有很多不懂,我还没有写完,可以运行,大家帮忙纠正下,那里需要改的,大家给点意见和代码。。。。谢谢了