third commit

master
1052720016@qq.com 6 years ago
parent 773b6d7796
commit 6bbd51dab0

BIN
2.exe

Binary file not shown.

@ -36,17 +36,17 @@ void credit(int n)
fp=fopen(fpname,"w+"); fp=fopen(fpname,"w+");
head=(struct student *)malloc(sizeof(struct student)); head=(struct student *)malloc(sizeof(struct student));
printf("请输入学生学号 姓名 性别 出生年 月 日 地址 电话 e_mail:"); printf("请输入学生学号 姓名 性别 出生年 月 日 地址 电话 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); 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(); 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); 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; end=head;
for(i=0;i<n;i++) for(i=1;i<n;i++)
{ {
next=(struct student *)malloc(sizeof(struct student)); next=(struct student *)malloc(sizeof(struct student));
printf("请输入学生学号 姓名 性别 出生年 月 日 地址 电话 e-mail:"); printf("请输入学生学号 姓名 性别 出生年 月 日 地址 电话 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); 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(); 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); 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->link=next;
end=next; end=next;
end->link=NULL; end->link=NULL;
@ -66,8 +66,8 @@ int show2(int n)
fp=fopen(fpname,"r+"); fp=fopen(fpname,"r+");
for(i=0;i<n;i++) 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); 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); 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); fclose(fp);
} }
} }
@ -86,10 +86,10 @@ scanf("%d",&checkname);
getchar(); getchar();
for(i=0;i<n;i++) 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); 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) 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); 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); fclose(fp);
return(1); return(1);
} }
@ -108,13 +108,14 @@ int search2(int n)
fp=fopen(fpname,"r+"); fp=fopen(fpname,"r+");
printf("请输入要查询信息的学生姓名:"); printf("请输入要查询信息的学生姓名:");
scanf("%s",&checkname); scanf("%s",&checkname);
getchar();
for(i=0;i<n;i++) 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); 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) if(strcmp(checkname,head->name)==0)
{ {
for(i=0;i<n;i++) for(i=0;i<n;i++)
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); 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); fclose(fp);
return(1); return(1);
} }
@ -133,11 +134,11 @@ int most(n)
gets(fpname); gets(fpname);
fp=fopen(fpname,"r+"); fp=fopen(fpname,"r+");
ans[0]=(struct student *)malloc(sizeof(struct student)); 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); 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++) for(i=0;i<n;i++)
{ {
ans[i]=(struct student *)malloc(sizeof(struct student)); 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); 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-1]->link=ans[i];
} }
ans[i]->link=NULL; ans[i]->link=NULL;
@ -154,7 +155,7 @@ int most(n)
if(strcmp(checkname,ans[i]->name)==0) if(strcmp(checkname,ans[i]->name)==0)
{ {
printf("请输入学生新信息 学号 姓名 性别 出生年 月 日 地址 电话 e-mail:"); printf("请输入学生新信息 学号 姓名 性别 出生年 月 日 地址 电话 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); 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(); getchar();
} }
} }
@ -177,7 +178,7 @@ int most(n)
fp=fopen(fpname,"w+"); fp=fopen(fpname,"w+");
for(i=0;i<n;i++) 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); 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); fclose(fp);
return(n); return(n);

BIN
3.exe

Binary file not shown.
Loading…
Cancel
Save