学生信息管理系统
来源:互联网 发布:网络服务提供商与数据 编辑:程序博客网 时间:2024/06/05 02:27
写了好几个小时手都要费了…..
#include<stdio.h>const int maxn=1e5;struct student{ char num[10]; /*学号*/ char name[15]; /*姓名*/ int cgrade; /*C语言成绩*/ int mgrade; /*数学成绩*/ int egrade; /*英语成绩*/ int total; /*总分*/ float ave; /*平均分*/ int mingci; /*名次*/ struct student *next;};void print() { printf(" The students' Grade Management System\n"); for(int i=0;i<25;i++) printf("*"); printf("Mune"); for(int i=0;i<25;i++) printf("*"); printf("\n"); printf("* 1 input record\t\t2 delete record *\n"); printf("* 3 search record\t\t4 modify record *\n"); printf("* 5 insert record\t\t6 count record *\n"); printf("* 7 sort record\t\t8 save record *\n"); printf("* 9 display record\t\t0 quit record *\n");}struct student *inputs(struct student*head) { struct student *p=NULL,*pr=head; p=(struct student*) malloc(sizeof(struct student)); if(p==NULL) { printf("No enough memory to allocate!\n"); exit(0); } if(head==NULL) head=p; else { while(pr->next!=NULL) pr=pr->next; pr->next=p; } printf("Input student information:\n"); printf("Please input student's number:"); scanf("%s",&p->num); printf("Please input student's name:"); scanf("%s",&p->name); printf("Please input student's C launage grade:"); scanf("%d",&p->cgrade); printf("Please input student's Math grade:"); scanf("%d",&p->mgrade); printf("Please input student's English grade:"); scanf("%d",&p->egrade); printf("Please input student's rank:"); scanf("%d",&p->mingci); p->total=p->cgrade+p->mgrade+p->egrade; p->ave=(double)p->total/3.0; //printf("%d %d %d\n",p->cgrade,p->mgrade,p->egrade); p->next=NULL; printf("You have input the student's information successful!\n"); return head;}struct student *deletes(struct student*head) { printf("Please input the student's name which you want to delect:"); char delect_name[15]; scanf("%s",&delect_name); struct student *p=head,*pr=NULL; if(head==NULL) { printf("Student's information is empty!\n"); return (head); } while(strcmp(delect_name,p->name)&&p->next!=NULL) { pr=p; p=p->next; } if(strcmp(delect_name,p->name)==0) { if(p==head) head=p->next; else pr->next=p->next; free(p); printf("The student information has been deleted\n"); } else printf("This student has not been found!\n"); return head;}void searchs(struct student*head) { printf("Please input the student's name which you want to search:"); char search_name[15]; scanf("%s",&search_name); struct student *p=head; if(head==NULL) { printf("Student's information is empty!\n"); return head; } while(strcmp(search_name,p->name)==0&&p->next!=NULL) { p=p->next; } if(strcmp(search_name,p->name)==0) { printf("The student's number is%s\n",p->num); printf("The student's number C language grade is %d\n",p->cgrade); printf("The student's number Math grade is %d\n",p->mgrade); printf("The student's number English grade is %d\n",p->egrade); printf("The student's number total grade is %d\n",p->total); printf("The student's number average grade is %f\n",p->ave); printf("The student's number rank is %d\n",p->mingci); } else printf("This student has not been found!\n"); return head;}struct student *modifys(struct student*head) { printf("Please input the student's name which you want to modify:"); char modify_name[15]; scanf("%s",&modify_name); struct student *p=head,*pr=NULL; if(head==NULL) { printf("Student's information is empty!\n"); return (head); } while(strcmp(modify_name,p->name)&&p->next!=NULL) { p=p->next; } if(strcmp(modify_name,p->name)==0) { printf("Please input the information you want to modify:"); printf("\n1.number\t2.name\n"); printf("3.C language grade\t4.Math grade\n"); printf("5.English grade\t6.rank\n"); int modify_number; scanf("%d",&modify_number); if(modify_number==1) { printf("Please input the new number:"); char new_number[20]; scanf("%s",&new_number); strcpy(p->num,new_number); //p->num=new_number; printf("The student's information modify successful\n"); } else if(modify_number==2) { printf("Please input the new name:"); char new_name[20]; scanf("%s",&new_name); strcpy(p->name,new_name); //p->name=new_name; printf("The student's information modify successful\n"); } else if(modify_number==3) { printf("Please input the new C language grade:"); int new_grade; scanf("%d",&new_grade); p->cgrade=new_grade; p->total=p->cgrade+p->mgrade+p->egrade; p->ave=(double)p->total/3.0; printf("The student's information modify successful\n"); } else if(modify_number==4) { printf("Please input the new Math grade:"); int new_grade; scanf("%d",&new_grade); p->mgrade=new_grade; p->total=p->cgrade+p->mgrade+p->egrade; p->ave=(double)p->total/3.0; printf("The student's information modify successful\n"); } else if(modify_number==5) { printf("Please input the new English grade:"); int new_grade; scanf("%d",&new_grade); p->egrade=new_grade; p->total=p->cgrade+p->mgrade+p->egrade; p->ave=(double)p->total/3.0; printf("The student's information modify successful\n"); } else if(modify_number==6) { printf("Please input the new rank:"); int new_rank; scanf("%d",&new_rank); p->mingci=new_rank; printf("The student's information modify successful\n"); } } else printf("This student has not been found!\n"); return head;}struct student *inserts(struct student*head) { printf("Please input the name do you want do insert:"); char insert_name[20]; scanf("%s",&insert_name); printf("Please input the name do you want to insert the %s after:",insert_name); char after_name[20]; scanf("%s",&after_name); struct student *p=NULL,*pr=head,*temp=NULL; p=(struct student*) malloc(sizeof(struct student)); if(head==NULL) { printf("Student's information is empty!\n"); return (head); } printf("Input student information:\n"); printf("Please input student's number:"); scanf("%s",&p->num); printf("Please input student's name:"); scanf("%s",&p->name); printf("Please input student's C launage grade:"); scanf("%d",&p->cgrade); printf("Please input student's Math grade:"); scanf("%d",&p->mgrade); printf("Please input student's English grade:"); scanf("%d",&p->egrade); printf("Please input student's rank:"); scanf("%d",&p->mingci); p->total=p->cgrade+p->mgrade+p->egrade; p->ave=(double)p->total/3.0; p->next=NULL; printf("You have input the student's information successful!\n"); while(strcmp(after_name,pr->name)!=0&&pr->next!=NULL) { pr=pr->next; } if(strcmp(after_name,pr->name)==0) { p->next=pr->next; pr->next=p; } else printf("This student has not been found!\n"); return head;}void counts(struct student*head) { struct student *p=head; if(head==NULL) { printf("student's information is empty!\n"); return (head); } int cgrades=0,mgrades=0,egrades=0; while(p!=NULL) { cgrades+=p->cgrade; mgrades+=p->mgrade; egrades+=p->egrade; p=p->next; } printf("The all students C language grade is %d\n",cgrades); printf("The all students Math grade is %d\n",mgrades); printf("The all students English grade is %d\n",egrades);}struct student *sorts(struct student*head) { struct student *f=NULL,*t=NULL, *max, *pr=NULL, *p; while(head!=NULL) { for(p=head,max=head;p->next!=NULL;p=p->next) if(p->next->cgrade>max->cgrade) { pr=p;max=p->next; } if(f==NULL) { f=max;t=max; } else{ t->next = max;t = max; } if (max==head) head = head->next; else pr->next = max->next; } t->next = NULL; printf("You sort the students' information with C language grade\n"); return f;}void saves(struct student*head) { FILE *w =fopen("output.txt","w"); struct student *p=head; while(p) { fprintf(w,"The student's number:%s\n",p->num); fprintf(w,"The student's name:%s\n",p->name); fprintf(w,"The student's C language grade:%d\n",p->cgrade); fprintf(w,"The student's Math grade:%d\n",p->mgrade); fprintf(w,"The student's English grade:%d\n",p->egrade); fprintf(w,"The student's total grade:%d\n",p->total); fprintf(w,"The student's average grade:%f\n",p->ave); fprintf(w,"The student's rank :%d\n\n\n",p->mingci); p=p->next; } fclose(w); printf("Save the students's information successfully!\n");}void displays(struct student*head) { struct student *p=head; if(head==NULL) { printf("student's information is empty!\n"); return (head); } while(p!=NULL) { printf("The students number is:%s\n",p->num); printf("The students name is:%s\n",p->name); printf("The students C language grade is:%d\n",p->cgrade); printf("The students Math grade is:%d\n",p->mgrade); printf("The students English grade is:%d\n",p->egrade); printf("The students sum grade is:%d\n",p->total); printf("The students average grade is:%f\n",p->ave); printf("The students rank is:%d\n\n\n",p->mingci); p=p->next; }}void release(struct student*head) { struct student *p=head,*pr=NULL; while(p!=NULL) { pr=p; p=p->next; free(pr); }}int main(){ print(); int x; struct student *head=NULL; while(scanf("%d",&x)&&x) { if(x>9) printf("please input the number from 0 to 9"); else { if(x==1) head=inputs(head); if(x==2) head=deletes(head); if(x==3) searchs(head); if(x==4) head=modifys(head); if(x==5) head=inserts(head); if(x==6) counts(head); if(x==7) head=sorts(head); if(x==8) saves(head); if(x==9) displays(head); } } release(head); printf("You had quit The students' Grade Management System\n"); return 0;}
阅读全文
1 0
- 学生信息管理系统
- 学生学籍信息管理系统
- 学生信息管理系统
- 学生信息管理系统
- 学生成绩信息管理系统
- 学生信息管理系统
- 【学生信息管理系统 总结】
- 学生信息管理系统--毕业论文
- 学生信息管理系统
- 学生信息管理系统
- 学生信息管理系统~~~~~
- 学生信息管理系统
- 学生信息管理系统总结
- 学生信息管理系统
- 学生信息管理系统
- 学生信息管理系统
- netbeans 学生信息管理系统
- 学生信息管理系统
- 拷贝构造函数和赋值构造函数声明为私有的作用
- 计算机组成原理(第六章:计算机的运算方法)
- 关于数据检测类型的浅谈
- 全排列(java)
- 数据结构中查找和排序算法总结及源码实现
- 学生信息管理系统
- 设计模式—桥接模式(十八)
- iOS UISlider的使用
- 在win10下使用vscode和winbash调试C代码
- HDU-2070 Fibbonacci Number
- CentOS7中systemctl的使用
- Mysql查询数据第二讲之单表查询
- C语言 指针例解
- 线性表——链式存储结构之循环双链表