下面贴出部分代码:
void add_tea(Teacher tea[])
{
int i=0,j,num;
char str[5];
if(numtea!=0)
{
printf("cover the current record (y/n)\n");
gets(str);
if(str[0]=='Y'||str[0]=='y')
i=0;
else i=numtea;
}
printf("Please input the number of you add the teachers:");
scanf("%d",&num);
if(i==0)
numtea=num;
else numtea+=num;
if(numtea>lens)
{
lens+=10;
tea=(Teacher *)realloc(tea,lens*SIZE);
}
printf("Please input the teacher's info:\n");
for(;i=0)
{
printf("Delete it (y/n)");
gets(str);
if(str[0]=='y'||str[0]=='Y')
{
delete_tea(tea,i);
/*count(stud); */
}
else
{
printf("Adjust it (y/n)");
gets(str);
if(str[0]=='y'||str[0]=='Y')
{
printf("Please input something you want:\n");
printf("please input the teacher's NO.:");
gets(tea.number);
printf("please input the teacher's name:");
gets(tea.name);
printf("please input the teacher's sex(man/woman 0/1):");
gets(tea.sex);
if(tea.sex[0]=='0') strcpy(tea.sex,"man");
else strcpy(tea.sex,"woman");
printf("please input the teacher's address:");
gets(tea.addr);
printf("the teacher is married(No/Yes 0/1):");
gets(tea.married);
if(tea.sex[0]=='0') strcpy(tea.sex,"No");
else strcpy(tea.sex,"Yes");
}
/*count(stud); */
}
display_tea(tea,0,numtea-1);
}
printf("Again to Adjust it (y/n)\n");
gets(str);
if(str[0]=='y'||str[0]=='Y')
i=-1;
else i=1;
}
}
int find_tea(Teacher tea[])
{
char str[10];
int i;
if(numtea==0)
{
printf("There is nothing\n");
return -1;
}
else
{
printf("what do you want your fashion \n1.number\t2.name\t3.addr\n");
gets(str);
if(str[0]=='1')
{
printf("please input the teacher's number:");
gets(str);
for(i=0;i<=numtea;i++)
if(strcmp(str,tea.number)==0)
{
display_tea(tea,i,i);
break;
}
else continue;
}
else if(str[0]=='2')
{
printf("please input the teacher's name:");
gets(str);
for(i=0;i<=numtea;i++)
if(strcmp(str,tea.name)==0)
{
display_tea(tea,i,i);
break;
}
else continue;
}
else if(str[0]=='3')
{
printf("please input the teacher's address:");
gets(str);
for(i=0;i<=numtea;i++)
if(strcmp(str,tea.addr)==0)
{
display_tea(tea,i,i);
break;
}
else continue;
}
if(i>numtea)
{
printf("Nothing has find\n");
return -1;
}
return i;
}
}
void delete_tea(Teacher tea[],int i)
{
int j;
while(i>=0)
{
for(j=i;j