急求c++通讯录管理系统!限期三天!真急!

这是我写的一个程序 麻烦你看一下 看能不能帮上你的忙

#include<stdio.h>

#include<string.h>

#include<ctype.h>

#define YN {do {yes_no=getch();printf("%c",yes_no);}while(yes_no!='y'&&yes_no!='Y'&&yes_no!='n'&&yes_no!='N');}

/*判断学号是否为空*/

#define XH {do {gets(temp.xh);}while(strcmp(temp.xh," ")==0);}

/*录入学生的学号、班级、姓名、性别、生日、籍贯、学院*/

#define SEX {do{printf("xingbie(w for woman,m for man):\n");gets(temp.xb);}while(temp.xb[0]!='w'&&temp.xb[0]!='m');}

#define LR {printf("banji:");gets(temp.bj);printf("xingming:");gets(temp.xm); SEX printf("shengri:");gets(temp.sr);printf("jiguan:");gets(temp.jg);printf("xueyuan:");gets(temp.xy);}

/*判断文件是否打开*/

#define PDW {if(fp==NULL) {printf("\n The file can't be opened\n");return;}}

#define PD {while(temp.xh[0]!='#'&&temp.bj[0]!='#'&&temp.xm[0]!='#'&&temp.xb[0]!='#'&&temp.sr[0]!='#'&&temp.jg[0]!='#'&&temp.xy[0]!='#');}

/*将学生的档案放进文件fp中*/

#define GS0 {fprintf(fp,"%10s%10s%10s%10s%10s%10s%10s\n",temp.xh,temp.bj,temp.xm,temp.xb,temp.sr,temp.jg,temp.xy);}

/*如果学生的信息不为空,则将该学生的信息输入文件fp中*/

#define PD1 {if(temp.xh[0]!='#'&&temp.bj[0]!='#'&&temp.xm[0]!='#'&&temp.xb[0]!='#'&&temp.sr[0]!='#'&&temp.jg[0]!='#'&&temp.xy[0]!='#') GS0}

/*从文件fp中接收学生的档案信息*/

#define GS {fscanf(fp,"%10s%10s%10s%10s%10s%10s%10s\n",temp.xh,temp.bj,temp.xm,temp.xb,temp.sr,temp.jg,temp.xy);}

/*通过结构体数组接收文件fp中的学生档案信息*/

#define GS1 {fscanf(fp,"%10s%10s%10s%10s%10s%10s%10s\n",stu[i].xh,stu[i].bj,stu[i].xm,stu[i].xb,stu[i].sr,stu[i].jg,stu[i].xy);}

/*通过结构体数组将学生信息传送到文件fp中*/

#define GS2 {fprintf(fp,"%10s%10s%10s%10s%10s%10s%10s\n",stu[i].xh,stu[i].bj,stu[i].xm,stu[i].xb,stu[i].sr,stu[i].jg,stu[i].xy);}

#define SRW {while(feof(fp)==0){GS1 i++;n++;}} /*判断是否已执行到文件尾,并用i,n记录学生人数*/

#define PT {printf("%c",choose);} /*回显所选数*/

#define PTF {printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n",temp.xh,temp.bj,temp.xm,temp.xb,temp.sr,temp.jg,temp.xy);}

#define PTF1 {printf("%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n",stu[i].xh,stu[i].bj,stu[i].xm,stu[i].xb,stu[i].sr,stu[i].jg,stu[i].xy);}

#define GS3 {printf("\nxuehao banji xingming xingbie shengri jiguan xueyuan \n");}

#define N 100

struct student

{char xh[10];

char bj[10];

char xm[10];

char xb[2];

char sr[10];

char jg[10];

char xy[10];

};

void menu(); /*函数声明*/

void creat();

void refert();

void delete();

void add();

void modify();

void show();

void tongji();

void order();

void password();

main()

{ char choose,yes_no;

do

{ menu(); /*调用菜单函数*/

printf("\n\t\t please choose(1-9):");

choose=getch();

switch(choose)

{case '1':PT creat();break;

case '2':PT refert();break;

case '3':PT password();

delete();break;

case '4':PT add();break;

case '5':PT password();

modify();break;

case '6':PT show();break;

case '7':PT tongji();break;

case '8':PT order();break;

case '9':PT break;

default:printf("\n %c choose wrong!\n",choose);

}

if(choose=='9')

break;

printf("do you want to cotinue?(y/n)\n");

YN

}while(yes_no=='y'||yes_no=='Y');

}

/*制作菜单*/

void menu()

{clrscr(); /*清屏*/

printf("\n\n\n");

printf("\t\tWelcome to the student information manage system!\n");

printf("\t\t the designer--------yourname \n");

printf("\t\t *********************************\n");

printf("\t\t * please input order number *\n");

printf("\t\t * 1----------------creat *\n"); /*录入学生档案*/

printf("\t\t * 2----------------refer to *\n"); /*查询学生档案*/

printf("\t\t * 3----------------delete *\n"); /*删除学生档案*/

printf("\t\t * 4----------------add *\n"); /*添加学生档案*/

printf("\t\t * 5----------------modify *\n"); /*修改学生档案*/

printf("\t\t * 6----------------show *\n"); /*显示学生档案*/

printf("\t\t * 7----------------tongji *\n"); /*统计同一个学院的学生人数*/

printf("\t\t * 8----------------order *\n"); /*学生档案的排序*/

printf("\t\t * 9----------------exit *\n"); /*退出*/

printf("\t\t *********************************\n");

}

/*录入学生档案*/

void creat()

{int i=1;

struct student temp;

FILE *fp;

fp=fopen("f:\\123.txt","w"); /*以只写方式打开文件,且测试*/

PDW

do{ clrscr();

printf(" every pace end with '#'\n ");

printf(" please input number %d information:\n",i);

printf(" xuehao:");

XH /*判断学号是否为空*/

LR /*录入学生的学号、班级、姓名、性别、生日、籍贯、学院*/

PD1 /*判断学生信息是否为空,并放进文件fp中*/

i++;

} while(temp.xh[0]!='#'&&temp.bj[0]!='#'&&temp.xm[0]!='#'&&temp.xb[0]!='#'&&temp.sr[0]!='#'&&temp.jg[0]!='#'&&temp.xy[0]!='#');

fclose(fp); /*关闭文件*/

}

/*查询学生档案*/

void refert()

{char c,mid[10],b[10];

FILE *fp;

int flag=0,n=0;

struct student temp;

fp=fopen("f:\\123.txt","r"); /*打开文件*/

PDW

clrscr();

printf("\n which way to refetr to ?number(1) or name(2)?choose(1-2):\n");

c=getch();

if(c=='2') /*按姓名查询*/

{ printf("\nPlease input the student's name\n");

gets(mid);

}

else if(c=='1') /*按学号查询*/

{ printf("\nPlease input number\n");

gets(mid);

}

else { printf("Error!");

return;

}

while(feof(fp)==0)

{ GS

if(c=='1')

strcpy(b,temp.xh); /*将学生的学号复制到b中*/

else

strcpy(b,temp.xm); /*将学生的姓名复制到b中*/

if(strcmp(mid,b)==0) /*比较大小函数*/

{ if(flag==0)

{ GS3

PTF

}

flag=1;

}

n++;

}

if(n==0) printf("no list!\n"); /*已经到文件尾*/

else if(flag==0)

printf("no find\n"); /*没有到文件尾,但没有此人*/

}

void delete() /*删除函数*/

{ char c,mid[10],b[10];

int n=0,i=0,k;

FILE *fp;

struct student stu[N];

fp=fopen("f:\\123.txt","r"); /*打开并测试文件*/

PDW /*判断文件是否打开*/

SRW /*判断是否已执行到文件尾,并用i,n记录学生人数*/

fclose(fp);

clrscr();

printf("\nPlease input the deleting student's way\n");

printf("\n1----number,2----name please choose(1-2):");

c=getch();

if(c=='1')

{ printf("\nplease input the student's number:");

gets(mid);

}

else if(c=='2')

{ printf("\nplease input name:");

gets(mid);

}

else {printf("Error!");return;}

for(i=0;i<n;i++)

{ if(c=='1')

strcpy(b,stu[i].xh); /*将学生的学号复制到b中*/

else

strcpy(b,stu[i].xm); /*将学生的姓名复制到b中*/

if(strcmp(mid,b)==0) break; /*将要删除的学生信息和原有的信息作比较*/

}

if(i<n)

for(k=i;k<n;k++)

stu[k]=stu[k+1];

else {printf("No the student!\n");return; }

fp=fopen("f:\\123.txt","w");

PDW

for(i=0;i<n-1;i++)

GS2 /*将学生信息传送到文件fp中*/

fclose(fp);

}

void add() /*添加学生信息函数*/

{

char c,yes_no;

int n=0,i=0;

struct student temp,stu[N];

FILE *fp;

fp=fopen("f:\\123.txt","r");

PDW /*判断文件是否打开*/

SRW /*判断是否已执行到文件尾,并用i,n记录学生人数*/

clrscr();

for(i=0;i<n;i++)

PTF1

do{ printf("\nplease input the new information:\n");

printf("xuehao:");

XH

LR

for(i=0;i<n;i++)

if(strcmp(temp.xh,stu[i].xh)==0) /*将要添加的学生学号和原有的学生学号做比较*/

{ printf("\nThe number is repeat do you want to input again(y/n)?:");

YN

putchar('\n');

break;

}

if(i==n) {stu[i]=temp;break;}

}while(yes_no=='y'||yes_no=='Y');

if(i<n&&yes_no=='n'){return;}

fp=fopen("f:\\123.txt","w");

PDW

for(i=0;i<=n;i++)

GS2 /*将学生信息传送到文件fp中*/

fclose(fp);

}

void modify() /* 修改学生信息函数*/

{char c,yes_no;

int n=0,i=0;

struct student *find,temp,stu[N],*p;

FILE *fp;

fp=fopen("f:\\123.txt","rb"); /*打开文件*/

PDW

SRW

fclose(fp);

if(n==0)

{ printf("\n No the information!\n");return;}

clrscr();

printf("\nPlease input the number of the modifying student:");

gets(temp.xh);

for(p=stu;p<stu+n;p++)

if(strcmp(temp.xh,p->xh)==0)

{ find=p;break;} /*用find记录要修改的学生学号*/

if(p==stu+n)

{ printf("No the person!\n");return;}

do

{ printf("\nPlease input the new student's information:\n");

printf("xuehao:");

gets(temp.xh);

XH /*判断学号是否为空*/

LR /*录入学生的学号、班级、姓名、性别、生日、籍贯、学院*/

for(p=stu;p<stu+n;p++)

if(strcmp(temp.xh,p->xh)==0&&p!=find)

{ printf("\nThe number is repeat, do you want to cotinue(y/n)?");

YN

putchar('\n');

break;

}

if(p==stu+n)

{ *find=temp; /*将新的学生信息赋给被修改的学生*/

break;

}

}while(yes_no=='y'||yes_no=='Y');

fp=fopen("f:\\123.txt","w");

PDW

for(i=0;i<n;i++)

GS2

fclose(fp);

}

void show() /*显示学生信息函数*/

{int n=0,i=0;

struct student stu[N];

FILE *fp;

fp=fopen("f:\\123.txt","r");

PDW

clrscr();

GS3

SRW /*判断是否已执行到文件尾,并用i,n记录学生人数*/

if(n==0)

{

printf("No the student");

return;

}

else

{ for(i=0;i<n;i++)

PTF1

}

printf("\nHave %d information",n);

fclose(fp);

}

void tongji() /*统计在同一个学院的学生人数*/

{int i=0,n=0,k=0;

char mid[10];

FILE *fp;

struct student stu[N];

fp=fopen("f:\\123.txt","r");

PDW

SRW

fclose(fp);

clrscr();

printf("\nplease input xueyuan name:");

gets(mid);

GS3

for(i=0;i<n;i++)

if(strcmp(mid,stu[i].xy)==0)

{ PTF1

k++; /*记录符合条件的学生人数*/

}

printf("\nThere are %d students in the same university!\n",k);

}

void order() /*排序函数*/

{int i=0,n=0;

struct student stu[N],*p,*q,temp;

FILE *fp;

char c;

fp=fopen("f:\\123.txt","r");

PDW

SRW

if(n==0)

{ printf("no the student!\n");return; }

else {clrscr();

printf("\nWhich way to order ?number(1) or name(2):\n");

printf("\nPlease choose(1-2):");

c=getch();

putchar(c);

if(c=='1')

{ for(p=stu;p<stu+n-1;p++)

for(q=p+1;q<stu+n;q++)

if(strcmp(p->xh,q->xh)>0)

{ temp=*p;

*p=*q;

*q=temp;

}

}

else if(c=='2')

{

for(p=stu;p<stu+n-1;p++)

for(q=p+1;q<stu+n;q++)

if(tolower(p->xm[0])>tolower(q->xm[0])) /*按字母排序*/

{temp=*p;

*p=*q;

*q=temp;

}

}

else {printf("Error");return;}

}

printf("\n higher(1) or lower(2) order?\n"); /*按升序排(1)还是降序(2)*/

printf("\nplease choose(1-2):\n");

c=getch();

putchar(c);

if(c=='1')

{GS3

for(i=0;i<n;i++)

{PTF1

GS2 /*将学生信息传送到文件fp中*/

}

}

else if(c=='2')

{GS3

for(i=n-1;i>=0;i--)

{PTF1

GS2

}

}

else {printf("Error");return;}

fclose(fp);

}

void password()

{char password[11]="123456",*p;

int count=0;

do

{if(count>0)

printf("Error!input again\n");

printf("please input password\n");

gets(p);

count++;

}while(strcmp(password,p)!=0&&count<3);

if(count>=3)

exit(1);

}