|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<io.h>
|
|
|
|
|
struct birth
|
|
|
|
|
{
|
|
|
|
|
int year,month,day;
|
|
|
|
|
};
|
|
|
|
|
struct student
|
|
|
|
|
{
|
|
|
|
|
int number,age,tel[20];
|
|
|
|
|
char name[10],sex,address[20];
|
|
|
|
|
char E_mail[20];
|
|
|
|
|
struct birth birthday;
|
|
|
|
|
struct student *link;
|
|
|
|
|
};
|
|
|
|
|
void show()
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּӻس<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
printf("1.ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ¼<CFA2>빦<EFBFBD><EBB9A6>(ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>)-<2D><><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("2.ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("3.ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>-<2D><>ѧ<EFBFBD>Ų<EFBFBD>ѯ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ\n");
|
|
|
|
|
printf("4.ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻس<EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
void credit(int n)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char fpname[20];
|
|
|
|
|
struct student *head,*next,*end;
|
|
|
|
|
int i;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",fpname);
|
|
|
|
|
getchar();
|
|
|
|
|
fp=fopen(fpname,"a+");
|
|
|
|
|
head=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><>ַ <20>绰 e_mail:");
|
|
|
|
|
scanf("%d %s %c %d %d %d %s %s %s",&head->number,head->name,&head->sex,&(*head).birthday.year,&(*head).birthday.month,&(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
getchar();
|
|
|
|
|
fprintf(fp,"%d %s %c %d %d %d %s %s %s",head->number,head->name,head->sex,(*head).birthday.year,(*head).birthday.month,(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
end=head;
|
|
|
|
|
for(i=1;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
next=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><>ַ <20>绰 e-mail:");
|
|
|
|
|
scanf("%d %s %c %d %d %d %s %s %s",&head->number,head->name,&head->sex,&(*head).birthday.year,&(*head).birthday.month,&(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
getchar();
|
|
|
|
|
fprintf(fp,"%d %s %c %d %d %d %s %s %s",head->number,head->name,head->sex,(*head).birthday.year,(*head).birthday.month,(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
end->link=next;
|
|
|
|
|
end=next;
|
|
|
|
|
end->link=NULL;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
int show2(int n)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i;
|
|
|
|
|
char fpname[20];
|
|
|
|
|
struct student *head;
|
|
|
|
|
head=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
gets(fpname);
|
|
|
|
|
fp=fopen(fpname,"r+");
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
fscanf(fp,"%d %s %c %d %d %d %s %s %s",&head->number,head->name,&head->sex,&(*head).birthday.year,&(*head).birthday.month,&(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
printf("%d %s %c %d %d %d %s %s %s",&head->number,head->name,head->sex,(*head).birthday.year,(*head).birthday.month,(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
int search1(int n)
|
|
|
|
|
{
|
|
|
|
|
int i,checkname;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char fpname[20];
|
|
|
|
|
struct student *head;
|
|
|
|
|
head=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
gets(fpname);
|
|
|
|
|
fp=fopen(fpname,"r+");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&checkname);
|
|
|
|
|
getchar();
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
fscanf(fp,"%d %s %c %d %d %d %s %s %s",&head->number,head->name,&head->sex,&(*head).birthday.year,&(*head).birthday.month,&(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
if(checkname==head->number)
|
|
|
|
|
{
|
|
|
|
|
printf("%d %s %c %d %d %d %s %s %s\n",head->number,head->name,head->sex,(*head).birthday.year,(*head).birthday.month,(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("δ<EFBFBD>ҵ<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
int search2(int n)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char fpname[20],checkname[20];
|
|
|
|
|
struct student *head;
|
|
|
|
|
head=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
gets(fpname);
|
|
|
|
|
fp=fopen(fpname,"r+");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&checkname);
|
|
|
|
|
getchar();
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
fscanf(fp,"%d %s %c %d %d %d %s %s %s",&head->number,head->name,&head->sex,&(*head).birthday.year,&(*head).birthday.month,&(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
if(strcmp(checkname,head->name)==0)
|
|
|
|
|
{
|
|
|
|
|
fprintf(fp,"%d %s %c %d %d %d %s %s %s",head->number,head->name,head->sex,(*head).birthday.year,(*head).birthday.month,(*head).birthday.day,head->address,head->tel,head->E_mail);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("δ<EFBFBD>ҵ<EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
int most(n)
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
char get;
|
|
|
|
|
char fpname[20];
|
|
|
|
|
struct student *ans[500];
|
|
|
|
|
int i;
|
|
|
|
|
char checkname[10];
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
gets(fpname);
|
|
|
|
|
fp=fopen(fpname,"r+");
|
|
|
|
|
ans[0]=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
fscanf(fp,"%d %s %c %d %d %d %s %s %s",&ans[0]->number,ans[0]->name,&ans[0]->sex,&(*ans[0]).birthday.year,&(*ans[0]).birthday.month,&(*ans[0]).birthday.day,ans[0]->address,ans[0]->tel,ans[0]->E_mail);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
ans[i]=(struct student *)malloc(sizeof(struct student));
|
|
|
|
|
fscanf(fp,"%d %s %c %d %d %d %s %s %s",&ans[i]->number,ans[i]->name,&ans[i]->sex,&(*ans[i]).birthday.year,&(*ans[i]).birthday.month,&(*ans[i]).birthday.day,ans[i]->address,ans[i]->tel,ans[i]->E_mail);
|
|
|
|
|
ans[i-1]->link=ans[i];
|
|
|
|
|
}
|
|
|
|
|
ans[i]->link=NULL;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ӻس<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>ӻس<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
get=getchar();
|
|
|
|
|
getchar();
|
|
|
|
|
if(get=='1')
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",checkname);
|
|
|
|
|
getchar();
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(checkname,ans[i]->name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ ѧ<><D1A7> <20><><EFBFBD><EFBFBD> <20>Ա<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><>ַ <20>绰 e-mail:");
|
|
|
|
|
scanf("%d %s %c %d %d %d %s %s %s",&ans[i]->number,ans[i]->name,&ans[i]->sex,&(*ans[i]).birthday.year,&(*ans[i]).birthday.month,&(*ans[i]).birthday.day,ans[i]->address,ans[i]->tel,ans[i]->E_mail);
|
|
|
|
|
getchar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(get=='2')
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",checkname);
|
|
|
|
|
getchar();
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(checkname,ans[i]->name)==0)
|
|
|
|
|
{
|
|
|
|
|
ans[i-1]->link=ans[i]->link;
|
|
|
|
|
n--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fp=fopen(fpname,"w+");
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
fprintf(fp,"%d %s %c %d %d %d %s %s %s",ans[i]->number,ans[i]->name,ans[i]->sex,(*ans[i]).birthday.year,(*ans[i]).birthday.month,(*ans[i]).birthday.day,ans[i]->address,ans[i]->tel,ans[i]->E_mail);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return(n);
|
|
|
|
|
}
|
|
|
|
|
void main ()
|
|
|
|
|
{
|
|
|
|
|
char get,get2;
|
|
|
|
|
int n;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
show();
|
|
|
|
|
get=getchar();
|
|
|
|
|
getchar();
|
|
|
|
|
switch(get)
|
|
|
|
|
{
|
|
|
|
|
case '1':
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
getchar();
|
|
|
|
|
credit(n);
|
|
|
|
|
break;
|
|
|
|
|
case '2':
|
|
|
|
|
show2(n);
|
|
|
|
|
break;
|
|
|
|
|
case '3':
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ѧ<EFBFBD>Ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ӻس<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>ӻس<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
get2=getchar();
|
|
|
|
|
getchar();
|
|
|
|
|
if(get2=='1')
|
|
|
|
|
search1(n);
|
|
|
|
|
if(get2=='2')
|
|
|
|
|
search2(n);
|
|
|
|
|
break;
|
|
|
|
|
case '4':
|
|
|
|
|
n=most(n);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(get!='1'&&get!='2'&&get!='3'&&get!='4')
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|