commit
8b69d12539
@ -0,0 +1,75 @@
|
|||||||
|
#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("请输入数字加回车键进行选择:\n");
|
||||||
|
printf("1.学生信息录入功能(学生信息用文件保存)-输入\n");
|
||||||
|
printf("2.学生信息浏览功能-输出\n");
|
||||||
|
printf("3.学生信息查询功能-按学号查询,按姓名查询\n");
|
||||||
|
printf("4.学生信息的删除与修改\n");
|
||||||
|
printf("按其他任意键加回车退出程序\n");
|
||||||
|
}
|
||||||
|
void credit(int n)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char fpname[20];
|
||||||
|
struct student *head,*next,*end;
|
||||||
|
int i;
|
||||||
|
printf("请输入用于存放文件的路径及路径名:");
|
||||||
|
scanf("%s",fpname);
|
||||||
|
getchar();
|
||||||
|
fp=fopen(fpname,"w+");
|
||||||
|
head=(struct student *)malloc(sizeof(struct student));
|
||||||
|
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);
|
||||||
|
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=0;i<n;i++)
|
||||||
|
{
|
||||||
|
next=(struct student *)malloc(sizeof(struct student));
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
void main ()
|
||||||
|
{
|
||||||
|
char get,get2;
|
||||||
|
int n;
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
get=getchar();
|
||||||
|
getchar();
|
||||||
|
switch(get)
|
||||||
|
{
|
||||||
|
case '1':
|
||||||
|
printf("请输入学生人数:");
|
||||||
|
scanf("%d",&n);
|
||||||
|
getchar();
|
||||||
|
credit(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in new issue