fclose (fp); return head; }
struct student *input()//添加函数 { char ch; struct student *p = NULL,*head=NULL;
head=p = (struct student*)malloc(sizeof(struct student)); p-> next = NULL; printf(\请输入要添加的学生的信息\\n\ printf(\学号:\ scanf(\ printf(\姓名: \ scanf(\ printf(\数学成绩:\ scanf(\ printf(\英语成绩:\ scanf(\ printf(\成绩:\ scanf(\ p -> sum = 0; p -> sum = p -> scorem + p -> scorec + p -> scoree; printf(\总分:%d\ for (;;) { printf (\是否继续输入学生信息?( y / n ):\\n\ getchar( ); ch = getchar ( ); if (ch == 'y'|| ch == 'Y') p = creat(p); else if(ch=='n'|| ch=='N') { save1 (head); break; } else printf (\您的输入有误,请重新输入,\ } return p->next; }
struct student *output()//输出函数,查看全部学生信息 { struct student *p ; p = read(); if(read==NULL) exit(1); printf(\
*************************STUDENT***********************\\n\ printf(\ -------------------------------------------------------\\n\ printf(\ | 学号 | 姓名 | 数学 | 英语 | C语言 | 总分 |\\n\ printf(\ -------------------------------------------------------\\n\ while (p != NULL)
{ p -> sum = 0; p -> sum = p -> scorem + p -> scoree + p -> scorec;
printf(\ | %4s | %-4s | = | = | = | = |\\n\ p->name,p->scorem,p->scoree,p->scorec,p->sum); printf(\ -------------------------------------------------------\\n\ p = p -> next; } return p; }
struct student *search()//查找函数 { int n; char a[9],b[9];
struct student *p = NULL,*head = NULL;
printf(\请您选择要查找的方式:1 按姓名 2 按学号\\n\ scanf(\ if(n==1) { printf(\请输入您要查找的学生的姓名:\\n\ scanf(\ p=head=read(); while(p!=NULL) { if(p==NULL) { printf(\对不起,没有您要找的人。\\n\ } if(strcmp(p -> name,a)==0) { printf(\
*************************STUDENT***********************\\n\ printf(\ -------------------------------------------------------\\n\ printf(\ | 学号 | 姓名 | 数学 | 英语 | C语言 | 总分 |\\n\ printf(\ -------------------------------------------------------\\n\
printf(\ | %4s | %-4s | = | = | = | = |\\n\ p->name,p->scorem,p->scoree,p->scorec,p->sum); printf(\ -------------------------------------------------------\\n\ break; } p=p->next; } }
if(n==2)
{ printf(\请输入您要查找的学生的学号:\\n\ scanf(\ p=head=read(); while(p!=NULL) { if(p==NULL) { printf(\对不起,没有您要找的人。\\n\ } if(strcmp(p -> num,b)==0) { printf(\
*************************STUDENT***********************\\n\ printf(\ -------------------------------------------------------\\n\ printf(\ | 学号 | 姓名 | 数学 | 英语 | C语言 | 总分 |\\n\ printf(\ -------------------------------------------------------\\n\
printf(\ | %4s | %-4s | = | = | = | = |\\n\ p->name,p->scorem,p->scoree,p->scorec,p->sum); printf(\ -------------------------------------------------------\\n\ break; } p=p->next; } } return head; }
struct student *dele()//删除函数 {
struct student *p1=NULL,*p2=NULL,*head=NULL; char a[9]; output(); printf (\请输入需要删除信息的人的姓名:\\n\ scanf (\ p1=head=read(); if(head==NULL) { printf(\对不起,暂时没有信息,无法删除。\\n\ }
while (head!=NULL) { if(strcmp(a,head -> name) != 0 && p1->next!=NULL ) { p2=head ; head= head->next ;
if(head==NULL) break; } if(strcmp(a,head -> name) == 0 && p1==head) { p1=head->next ; } if(strcmp(a,head->name)==0) { p2->next=head->next; save2(p1); printf(\该学生的信息删除成功!\ break; } } if(head==NULL) printf(\对不起,没有该学生的信息。\\n\ return head; }
struct student *change()//修改函数 { int a; char x[9]; struct student *p = NULL,*head = NULL,*q = NULL; output(); p = head = read(); printf(\请输入要修改的人的姓名:\\n\ scanf(\ if(p == NULL) { printf(\没有这个人!\\n\ exit(1); } while (p != NULL) { if (strcmp(p -> name,x) == 0) { q = p; break; } p = p -> next; } if(p!=NULL) { printf(\请选择修改的内容:\\n\ printf(\姓名\\n\ printf(\学号\\n\
printf(\数学成绩\\n\ printf(\英语成绩\\n\ printf(\成绩\\n\ do { scanf (\ if(a < 0 || a > 6) printf (\您输入的数字有误,请重新输入:\\n\ }while (a<=0||a>=6); switch (a) { case 1 : printf(\请输入更改后的姓名:\\n\ scanf(\ break; case 2 : printf(\请输入更改后的学号:\\n\ scanf(\ break; case 3 : printf(\请输入更改后的数学成绩:\\n\-> scorem);break; case 4 : printf(\请输入更改后的英语成绩:\\n\-> scoree);break; case 5 : printf(\请输入更改后的C成绩:\\n\ scanf(\-> scorec);break; } p->sum =0; p->sum=p->scorem +p->scoree +p->scorec ; printf(\更改后的总分:%d\ save2 (head); output(); } if(p==NULL) { printf(\对不起,没有这个人。\\n\ } return head; }
struct student *sortsum(struct student *head)//排序函数 {
struct student *p,*p1,*p2,*p3; struct student m, n;
if (head == NULL) return NULL; m.next=head; p=&m;
while (p->next!=NULL) {
p=p->next; }
p=p->next=&n; while (p!=m.next)