You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
6.4 KiB

6 years ago
#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();
6 years ago
fp=fopen(fpname,"a+");
6 years ago
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:");
6 years ago
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);
6 years ago
getchar();
6 years ago
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);
6 years ago
end=head;
6 years ago
for(i=1;i<n;i++)
6 years ago
{
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:");
6 years ago
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);
6 years ago
getchar();
6 years ago
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);
6 years ago
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++)
{
6 years ago
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);
6 years ago
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);
6 years ago
}
6 years ago
fclose(fp);
6 years ago
}
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++)
{
6 years ago
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);
6 years ago
if(checkname==head->number)
{
6 years ago
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);
6 years ago
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);
6 years ago
getchar();
6 years ago
for(i=0;i<n;i++)
{
6 years ago
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);
6 years ago
if(strcmp(checkname,head->name)==0)
{
6 years ago
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);
6 years ago
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));
6 years ago
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);
6 years ago
for(i=0;i<n;i++)
{
ans[i]=(struct student *)malloc(sizeof(struct student));
6 years ago
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);
6 years ago
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:");
6 years ago
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);
6 years ago
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++)
{
6 years ago
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);
6 years ago
}
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;
}
}