学生信息管理系统c语言版
学生管理系统c语言简单版
学生管理系统c语言简单版学生管理系统c语言简单版介绍:学生管理系统是一种用于管理学生信息的软件,它可以方便地对学生的基本信息、课程成绩等进行录入、查询、修改和删除等操作。
本文将介绍如何使用C语言编写一个简单的学生管理系统。
功能:1. 添加学生信息2. 查询学生信息3. 修改学生信息4. 删除学生信息5. 显示所有学生信息实现方法:1. 添加学生信息添加学生信息需要输入以下内容:姓名、性别、年龄、班级和电话号码。
我们可以定义一个结构体来存储这些信息,代码如下:```struct Student {char name[20];char sex[10];int age;char class[20];char phone[20];};```然后定义一个数组来存储多个学生的信息:```struct Student students[100];int count = 0; // 学生数量```接下来,我们可以编写一个函数来添加新的学生信息:```void addStudent() {struct Student student;printf("请输入姓名:");scanf("%s", );printf("请输入性别:");scanf("%s", student.sex);printf("请输入年龄:");scanf("%d", &student.age);printf("请输入班级:");scanf("%s", student.class);printf("请输入电话号码:");scanf("%s", student.phone);students[count++] = student; // 将新的学生信息存储到数组中 printf("添加成功!\n");}```2. 查询学生信息查询学生信息可以按照姓名或电话号码进行查询。
C语言学生信息管理系统(源代码)
#include <stdio.h>#include <string.h>/* 谭法建立单链表和输出单链表*/#include <malloc.h>#include <stdlib.h>typedef struct node{ int num;char name[20];struct node *next;}STD;#define LEN sizeof(STD)int menu_select();void handle_menu1();void game4();void game2();STD *insert(STD *head,STD *stud);STD *insert2(STD *head,STD *stud); void game3();void game5();STD *delete(STD*head,long num);void game1();void game6();STD *search(STD*head,long num);STD *head1,*head2;int n=0;/*追加法建表*/void creat1(void){ STD *p1,*p2;system("CLS");head1=NULL;p1=(STD *)malloc(LEN);p2=p1;printf("建表方法1追加法建表!\n");printf("输入学号姓名,若输入学号为0则退出建表!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ n++;if(n==1)head1=p1;elsep2->next=p1;p2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}free(p1); p2->next=NULL;scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");return ;}/* 插入法建表*/void creat2(void){ STD *p1;head2=NULL;system("CLS");p1=(STD *)malloc(LEN);printf("建表方法2插入法建表!\n");printf("输入学号姓名(输入学号以0结束)!\n");scanf("%d%s",&p1->num,p1->name);while(p1->num!=0){ p1->next=head2;head2=p1;p1=(STD *)malloc(LEN);scanf("%d%s",&p1->num,p1->name);}scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");free(p1);return ;}/* 链表输出*/void print(STD *head){ STD *p;p=head;while (p!=NULL){ printf("学号%3d 姓名%s\n",p->num,p->name); p=p->next;} printf("链表为空!\n");scanf("%*c");printf("按回车键继续!\n");getchar();system("CLS");}/*-------------------------------------------------*//*--------------表1插入结点函数-------*//*-------------------------------------------------*/void game4(){char ch;STD *stud,*head=head1;system("CLS");printf("\t仅限在表1中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head1=insert(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2插入结点函数-------*//*-------------------------------------------------*/void game2(){char ch;STD *stud,*head=head2;system("CLS");printf("\t仅限在表2中插入!\n");printf("\t输入要插入结点的学号和姓名(以空格隔开):");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);if(stud->num<0){ printf("\t输入的学号不能为负数,请重新选择插入!\n");return;}while(stud->num>=0){head2=insert2(head,stud);printf("\t继续插入新结点吗?(y/n):");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入新结点学号姓名:(输入n结束插入)");stud=(STD *)malloc(LEN);scanf("%*c");scanf("%d%s",&stud->num,&stud->name);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 插入模块*//**************************************/STD *insert(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num>p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num<=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/**************************************//* 插入模块2 *//**************************************/STD *insert2(STD *head,STD *stud){STD *p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num<p1->num)&&(p1->next!=NULL)){p2=p1; p1=p1->next;}if(p0->num>=p1->num){if(head==p1)head=p0;else p2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}n=n+1;printf("按回车键继续!\n");getchar();system("CLS");return (head);}/*-------------------------------------------------*//*--------------表1删除学生信息-------*//*-------------------------------------------------*/void game3(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head1;head1=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2删除学生信息-------*//*-------------------------------------------------*/void game5(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中删除!\n");printf("\t输入要删除的学号:");scanf("%*c");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新选择删除!\n");return;}while(num>=0){head=head2;head2=delete(head,num);printf("\t继续删除吗?(y/n):");scanf("%*c");ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要删除的学号:(输入n结束删除!)");scanf("%*c");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 删除模块*//**************************************/STD *delete(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1==head)head=p1->next;else p2->next=p1->next;printf("\n删除:%ld\n",num);n=n-1;}elseprintf("\n 没有发现此项! \n",num);system("CLS");return(head);}/*-------------------------------------------------*//*--------------表1查找学生信息-------*//*-------------------------------------------------*/void game1(){ int num;char ch;STD *head=head1;printf("\t仅限在表1中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head1;head1=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/*-------------------------------------------------*//*--------------表2查找学生信息-------*//*-------------------------------------------------*/void game6(){ int num;char ch;STD *head=head2;printf("\t仅限在表2中查找!\n");printf("\t输入要查找的学号:");scanf("%ld",&num);if(num<0){ printf("\t输入的学号不能为负数,请重新查找!\n");return;}while(num>=0){head=head2;head2=search(head,num);printf("\t继续查找吗?(y/n):");scanf("%d",&num);ch=getchar();if(ch=='y'||ch=='Y'){ printf("\t输入要查找的学号:(输入n结束查找)");scanf("%ld",&num);}elsebreak;}printf("\t输入回车键返回!\n");getchar();system("CLS");printf("\n");}/**************************************//* 查找模块*//**************************************/STD *search(STD*head,long num){STD *p1,*p2;if (head==NULL) {printf("\n没有找到该学号!\n");return head;} p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num)printf("\n%d %s\n",p1->num,p1->name);elseprintf("\n 没有发现此项! \n",num);return(head);}/* void main(){printf(" *** 运行结果***\n");printf("输入学号姓名(输入学号以0结束)!\n");creat1();print(head1);creat2();print(head2);} *///******************************//* select.cpp:主程序文件*//******************************void main(){handle_menu1();}//*****************************//* 菜单处理函数*//*****************************void handle_menu1(){int h;for(;;){h=menu_select();switch(h){ case 1:/* printf("\t进入追加法建表\n"); */creat1();break; /* 调用功能模块*/case 2:/* printf("\t进入插入法建表\n"); */creat2();break;case 3:/* printf("\t输出追加法链表的结果\n"); */print(head1);break;case 4:/* printf("\t输出插入法链表的结果\n"); */print(head2);break;case 5:/* printf("\t链表1插入\n"); */game4();break;case 6:/* printf("\t链表2插入\n"); */game2();break;case 7:/* printf("\t链表1删除\n"); */game3();break;case 8:/* printf("\t链表2删除\n"); */game5();break;case 9:/* printf("\t链表1查找\n"); */game1();break;case 10:/* printf("\t链表2查找\n"); */game6();break;case 11:printf("\t再见,欢迎再次使用本系统!谢谢!\n");return;}}}//**********************************//* 菜单选择函数: int menu_select()*//**********************************int menu_select(){int cn;for(;;){printf("\ \n");printf("\t1.追加法建表\n");printf("\ \n");printf("\t2.插入法建表\n");printf("\ \n");printf("\t3.输出链表1\n");printf("\ \n");printf("\t4.输出链表2\n");printf("\ \n");printf("\t5.插入链表1 \n");printf("\ \n");printf("\t6.插入链表2 \n");printf("\ \n");printf("\t7.删除链表1 \n");printf("\ \n");printf("\t8.删除链表2 \n");printf("\ \n");printf("\t9.查找链表1 \n");printf("\ \n");printf("\t10.查找链表2 \n");printf("\ \n");printf("\t11.退出系统\n");printf("\ \n");printf("\t请您选择1-11:");scanf("%d",&cn);//gets(s);//cn=atoi(s);if(cn<1||cn>11)printf("\n\t输入错误,重选1-11:");elsebreak;}return cn;}。
学生信息管理系统(C语言)
#include<stdio.h>#include<string.h>int stu_sum = 0;struct Student{int rollno;char name[10];char address[30];char username[10];char password[10];float EnglishMarks;float MathsMarks;float ScienceMarks;float total;float average;char grade;}studlist[10];void main_menu(){printf(" Student Information Management System\n");printf("***********************************************************\n");printf("1.Login as Administrator\n");printf("2.Login as Student\n");printf("3.Exit\n");printf("***********************************************************\n");printf("Enter Y our Choice:");}void admin_menu(){printf(" Welcome Admin\n");printf("***********************************************************\n");printf("Admin Menu\n");printf("1. Register Student\n");printf("2. Exit\n");printf("***********************************************************\n");printf("Enter Y our Choice:");}void student_menu(){printf(" Welcome Student\n");printf("***********************************************************\n");printf("Student Menu\n");printf("1. V iew Marks\n");printf("2. Exit\n");printf("***********************************************************\n");printf("Enter Y our Choice:");}void registe(int id){printf("Enter Details of Student\n");printf("Rollno:");scanf("%d",&studlist[id].rollno);printf("Name:");scanf("%s",&studlist[id].name);printf("Address:");scanf("%s",&studlist[id].address);printf("Usename:");scanf("%s",&studlist[id].username);printf("Password:");scanf("%s",&studlist[id].password);printf("EnglishMarks:");scanf("%f",&studlist[id].EnglishMarks);printf("MathsMarks:");scanf("%f",&studlist[id].MathsMarks);printf("ScienceMarks:");scanf("%f",&studlist[id].ScienceMarks);printf("Student Registered Successfully !!!\n");}void mark_view(int i){studlist[i].total = studlist[i].EnglishMarks + studlist[i].MathsMarks + studlist[i].ScienceMarks;studlist[i].average = studlist[i].total / stu_sum;if(studlist[i].average >= 90){studlist[i].grade = 'A';}else if(studlist[i].average>=75 && studlist[i].average<90){studlist[i].grade = 'B';}else if(studlist[i].average>=50 && studlist[i].average<75){studlist[i].grade = 'C';}else{studlist[i].grade = 'F';}//print tabulationprintf("English\tMath\tScience\tTotal\tA verage\tGrade\t\n");printf("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%c\t\n",studlist[i].EnglishMarks,studlist[i].MathsMark s,studlist[i].ScienceMarks,studlist[i].total,studlist[i].average,studlist[i].grade);}void main(){int i=0;int main_flag=1, admin_flag=1, student_flag=1;int main_choice,admin_choice,student_choice;char admin_name[10],admin_password[10],stu_name[10],stu_password[10];char admin[10] = "admin";while(main_flag){main_menu();//mainmenuscanf("%d",&main_choice);switch(main_choice){case 1:printf("Enter Username:");scanf("%s",admin_name);printf("Enter Password:");scanf("%s",admin_password);if(strcmp(admin_name,admin) != 0 || strcmp(admin_password,admin) != 0){printf("Name or Password error!\n");break;}while(admin_flag){admin_menu();//adminmenuscanf("%d",&admin_choice);switch(admin_choice){case 1:registe(stu_sum);stu_sum++;break;case 2:admin_flag = 0;break;}}break;case 2:printf("Enter Username:");scanf("%s",stu_name);printf("Enter Password:");scanf("%s",stu_password);while(i<stu_sum){if(strcmp(studlist[i].name,stu_name) == 0)break;i++;}if(strcmp(studlist[i].username,stu_name) != 0 || strcmp(studlist[i].password,stu_password) != 0){printf("Name or Password error!\n");break;}while(student_flag){student_menu();scanf("%d",&student_choice);switch(student_choice){case 1:mark_view(i);stu_sum++;break;case 2:student_flag = 0;break;}}break;case 3:main_flag = 0;break;}} }。
C实现简单的学生信息管理系统控制台程序
C实现简单的学生信息管理系统控制台程序学生信息管理系统是一种用于管理学生的基本信息的应用程序。
在这个系统中,可以实现学生信息的录入、修改、查询和删除等功能,以便对学生信息进行有效的管理和维护。
下面是一个用C语言实现的简单学生信息管理系统的示例代码。
```c#include <stdio.h>#include <stdlib.h>//定义学生结构体struct studentint id;char name[50];int age;};//全局变量,用于存储学生信息struct student students[100];int count = 0;//函数声明void menu(;void addStudent(;void listStudents(;void searchStudent(;void deleteStudent(;void updateStudent(;//主函数int maimenu(;return 0;//菜单函数void menint choice;doprintf("\n====== Student Information Management System ======\n");printf("1. Add student\n");printf("2. List students\n");printf("3. Search student\n");printf("4. Delete student\n");printf("5. Update student\n");printf("0. Exit\n");printf("Please enter your choice: "); scanf("%d", &choice);switch (choice)case 1:addStudent(;break;case 2:listStudents(;break;case 3:searchStudent(;break;case 4:deleteStudent(;break;case 5:updateStudent(;break;case 0:printf("Exit the system\n");break;default:printf("Invalid choice! Please try again\n");break;}} while (choice != 0);//添加学生函数void addStudenif (count >= 100)printf("The number of students has reached the upper limit!\n");return;}struct student newStudent;printf("Please enter student ID: ");scanf("%d", &newStudent.id);printf("Please enter student name: ");scanf("%s", );printf("Please enter student age: ");scanf("%d", &newStudent.age);students[count] = newStudent;count++;printf("Add student successfully!\n");//列出学生函数void listStudentif (count == 0)printf("No student information is available!\n");return;}printf("====== Student List ======\n");printf("ID\tName\t\tAge\n");for (int i = 0; i < count; i++)printf("%d\t%s\t\t%d\n", students[i].id, students[i].name, students[i].age);}void searchStudenif (count == 0)printf("No student information is available!\n"); return;}int id;printf("Please enter student ID: ");scanf("%d", &id);for (int i = 0; i < count; i++)if (students[i].id == id)printf("Student Information:\n");printf("ID: %d\n", students[i].id);printf("Name: %s\n", students[i].name);printf("Age: %d\n", students[i].age);return;}}printf("Student with ID %d does not exist!\n", id);void deleteStudenif (count == 0)printf("No student information is available!\n"); return;}int id;printf("Please enter student ID: ");scanf("%d", &id);for (int i = 0; i < count; i++)if (students[i].id == id)for (int j = i; j < count - 1; j++)students[j] = students[j+1]; // 将后面的学生信息往前移动}count--;printf("Delete student successfully!\n");return;}}printf("Student with ID %d does not exist!\n", id); //更新学生函数void updateStudenif (count == 0)printf("No student information is available!\n"); return;}int id;printf("Please enter student ID: ");scanf("%d", &id);for (int i = 0; i < count; i++)if (students[i].id == id)printf("Please enter student name: ");scanf("%s", students[i].name);printf("Please enter student age: ");scanf("%d", &students[i].age);printf("Update student information successfully!\n"); return;}}printf("Student with ID %d does not exist!\n", id);```这是一个简单的学生信息管理系统控制台程序,实现了学生的添加、列出、查询、删除和更新等功能。
C语言学生信息管理系统(完整版)
#define PRINT0 printf("name:%s\nsex:%s\nage:%d\nID_card:%d\naddress:%s\n",st[i].name,st[i].sex,st[i].age,st[i] .ID_card,st[i].addr)#define PRINT1 printf("prefession:%s\nstudent_number:%d\n*****score*****\nwuli:%d\n",st[i].prefession,st[i] .student_number,st[i].score.wuli)#define PRINT2 printf("gaoshu:%d\nyingyu:%d\ntiyu:%d\naverage: %d\n",st[i].score.gaoshu,st[i].score.yingyu,st[i ].score.tiyu,st[i].score.aver)#define print1 printf("________________________________")#define N 2#include "string.h"#include "stdio.h"int sum=0;struct score{int wuli;int gaoshu;int yingyu;int tiyu;int aver;};struct message{ char name[10];int age;char sex[5];int ID_card;char addr[30];char prefession[30];int student_number;struct score score;}st[100];/*************write message*************/write_message(){ int flag;char chioce;do{system("cls");flag=2; sum++;printf("_______________________________");printf("please input student's message:\n");printf("\n");print1;printf("%dth student message:",sum);print1;printf("\nname:");scanf("%s",st[sum].name);printf("\nsex:");scanf("%s",st[sum].sex);printf("\nage:");scanf("%d",&st[sum].age);printf("\nID_card:");scanf("%d",&st[sum].ID_card);printf("\naddress:");scanf("%s",st[sum].addr);printf("\nprefession:");scanf("%s",st[sum].prefession);printf("\nschool number:");scanf("%d",&st[sum].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[sum].score.wuli);printf("\ngaoshu:");scanf("%d",&st[sum].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[sum].score.yingyu);printf("\ntiyu:");scanf("%d",&st[sum].score.tiyu);printf("\naverage:");scanf("%d",&st[sum].score.aver);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*************save message****************/save_message(){ FILE *fp;int i;if((fp=fopen("student.txt","wb"))==NULL){printf("read error \n");printf("press any key back to menu\n");getch();exit(1);}for(i=0;i<sum;i++)if(fwrite(&st[i],sizeof(struct message),1,fp)!=1){printf("write error\n");fclose(fp);}fclose(fp);printf("\n********___OK!___**********\n___press any key back___");sum=i;bioskey(0);}/***************add message*****************/add_message(){int i,j,flag; char chioce;i=0;j=sum-1;flag=0;do{ system("cls");i++; j++;print1;printf("add %dth student's meaasge\n",i);print1;printf("\nname:");scanf("%s",st[j].name);printf("\nsex:");scanf("%s",st[j].sex);printf("\nage:");scanf("%d",&st[j].age);printf("\nID_card:");scanf("%d",&st[j].ID_card);printf("\naddress:");scanf("%s",st[j].addr);printf("\nprefession:");scanf("%s",st[j].prefession);printf("\nstudent_number:");scanf("%d",&st[j].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[j].score.wuli);printf("\ngaoshu:");scanf("%d",&st[j].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[j].score.yingyu);printf("\ntiyu:");scanf("%d",&st[j].score.tiyu);printf("\naverage:");scanf("%d",&st[j].score.aver);printf("\n\nweather add %dth student's message: \n",i+1);do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;}while(1);}while(flag==1);sum=j+1;save_message();}/**********inqiure message******/inqiure_message(){int chioce;do{system("cls");printf("**********choose 0-3**********\n\n\n");printf(" 1:name inquire\n\n\n");printf(" 2:IDcard inqiure\n\n\n");printf(" 3:student_number\n \n\n");printf(" 0:back menu\n\n\n");scanf("%d",&chioce);switch(chioce){case 1: name_inqiure();break;case 2: ID_card_inqiure();break;case 3: grade_inqiure();break;case 0:break;}}while(chioce!=0);}/**********name inqiure*********/name_inqiure(){char NAME[30];int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nname:");scanf("%s",NAME);getchar();printf("\n");for(i=0;i<sum;i++){if(strcmp(st[i].name,NAME)==0){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/**********IDcard inqiure*********/ID_card_inqiure(){int card;int i; int flag,k;char chioce;do{ clrscr(); k=0;printf("please input the message you inqiure");printf("\nIDcard:");scanf("%d",&card);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].ID_card==card){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********grade inqiure***********/grade_inqiure(){int GRADE;int i; int flag,k;char chioce;do{ system("cls");k=0;printf("please input the message you inqiure");printf("\nstudent_number:");scanf("%d",&GRADE);getchar();printf("\n");for(i=0;i<sum;i++){if(st[i].student_number==GRADE){PRINT0;PRINT1;PRINT2;k=1;}}if(k==0) printf("without message you inqiure\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);printf("press any key return to menu");bioskey(0);}/*********change message**********/change_message(){char pre[30],chioce;int i,gra,flag,num,s;s=0;do{system("cls");printf("please input message you want to change\n ");printf("student_number:");scanf("%d",&gra); getchar();for(i=0;i<sum;i++){if(st[i].student_number==gra){PRINT0;PRINT1;PRINT2;printf("\n********input message you want to change********\n");printf("0:name***1:sex***2:age***3:ID_card***4:address***\n5:prefession***6:wuli***7:stud ent_number***8\n:gaoshu***9:yingyu***10:tiyu***11:average***________\n");printf("choose 0-11\n");scanf("%d",&num); getchar();switch(num){case 0: printf("input the name changed\n");scanf("%s",st[i].name); getchar(); break;case 1: printf("input the sex changed\n");scanf("%s",st[i].sex); getchar(); break;case 2: printf("input the age changed\n");scanf("%d",&st[i].age); getchar(); break;case 3: printf("input the ID_card changed\n");scanf("%d",&st[i].ID_card); getchar(); break;case 4: printf("input the address changed\n");scanf("%s",st[i].addr); getchar(); break;case 5: printf("input the prefession changed\n");scanf("%s",st[i].prefession); getchar(); break;case 6: printf("input the wuli_score changed\n");scanf("%d",&st[i].score.wuli); getchar(); break;case7: printf("input the student_number changed\n");scanf("%d",&st[i].student_number); getchar(); break;case 8: printf("input the gaoshu_score changed\n");scanf("%d",&st[i].score.gaoshu); getchar(); break;case 9: printf("input the yingyu_score changed\n");scanf("%d",&st[i].score.yingyu); getchar(); break;case 10: printf("input the tiyu_score changed\n");scanf("%d",&st[i].score.tiyu); getchar(); break;case 11: printf("input the average_score changed\n");scanf("%d",&st[i].score.aver); getchar(); break;default: printf("input error\n"); break;}printf("\n*********the changed message*********\n\n");PRINT0;PRINT1;PRINT2;s=1;}}if(s!=1) printf("without message you want to change\n");do{ printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce); getchar();printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********delete message**********/delete_message(){ int GRADE;int i,j,flag1,flag;char chioce1,chioce2;flag1=3;flag=3;do{ system("cls");printf("please input student's student_number you want to delete\n");printf("student_number:");scanf("%d",&GRADE); getchar();for(i=0;i<sum;i++)if(st[i].student_number==GRADE){do{PRINT0;PRINT1;PRINT2;printf("\n******************************\n_________________ _________________\n");printf("press y/Y deleted:\npress n/N cancel:\n");scanf("%c",&chioce1);getchar();system("cls");if(chioce1=='y'||chioce1=='Y') flag1=1;else if(chioce1=='n'||chioce1=='N') return;else {printf("***input error***\n___press any ker return___\n"); bioskey(0);}}while(flag1!=1);for(j=i;j<sum;j++){ st[j]=st[j+1];flag=2;printf("message was deleted\n");sum-=1; }}if(flag!=2) printf("without message you want to delete\n");do{printf("press y/Y continue:\npress n/N stop:\n");scanf("%c",&chioce2);printf("****************************\n");if(chioce2=='y'||chioce2=='Y') {flag=1; break;}else if(chioce2=='n'||chioce2=='N') {flag=0; break;}else {system("cls");printf("input error\n");}print1;printf("\n");}while(1);}while(flag==1);save_message();}/************insert message*************/insert_message(){ int chioce,flag,i; flag=2;do{system("cls");printf("please input the number of people you insert\n");scanf("%d",&chioce);if(chioce>=sum){printf("xin xi pai zai zui hou ");chioce=sum;}for(i=sum;i>chioce;i--) st[i]=st[i-1];printf("\nplease input message you insert");printf("\nname:");scanf("%s",st[i].name);printf("\nsex:");scanf("%s",st[i].sex);printf("\nage:");scanf("%d",&st[i].age);printf("\nID_card:");scanf("%d",&st[i].ID_card);printf("\naddress:");scanf("%s",st[i].addr);printf("\nprefession:");scanf("%s",st[i].prefession);printf("\ngrade:");scanf("%d",&st[i].student_number);printf("\n*****score******\n");printf("wuli:");scanf("%d",&st[i].score.wuli);printf("\ngaoshu:");scanf("%d",&st[i].score.gaoshu);printf("\nyingyu:");scanf("%d",&st[i].score.yingyu);printf("\ntiyu:");scanf("%d",&st[i].score.tiyu);printf("\naverage:");scanf("%d",&st[i].score.aver);sum+=1;do{printf("****************************\n");printf("press y/Y continue:\npress n/N stop:\n");getchar();scanf("%c",&chioce);printf("****************************\n");if(chioce=='y'||chioce=='Y') {flag=1; break;}else if(chioce=='n'||chioce=='N') {flag=0; break;}else printf("input error\n");print1;printf("\n");}while(1);}while(flag==1);save_message();}/*********school_number_order***********/grade_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].student_number>st[j].student_number){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("grade order from min to max\n");for(i=0;i<sum;i++){ print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);bioskey(0);}/***********wuli score order***************/wuli_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("wuli score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********gaoshu score order***************/gaoshu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.gaoshu>st[j].score.gaoshu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("gaoshu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********yingyu score order***************/yingyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.yingyu>st[j].score.yingyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yingyu score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********tiyu score order***************/tiyu_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.tiyu>st[j].score.tiyu){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("yitu order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/***********average score order***************/average_order(){int i,j;system("cls");if(sum==0) {printf("**********no message**********\n____press any key return____");getch();return;}for(i=0;i<sum;i++)for(j=i+1;j<sum;j++)if(st[i].score.wuli>st[j].score.wuli){ st[sum+1]=st[i];st[i]=st[j];st[j]=st[sum+1];}printf("average score order from min to max\n");for(i=0;i<sum;i++){print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;getch();system("cls");}print1;printf("\ntotle num :%d\npress any key return to menu\n",sum);print1;bioskey(0);}/********order message****************/order_message(){int chioce;do{system("cls");printf("**********choose 0-6**********\n\n");printf(" 1:grade order\n\n");printf(" 2:wuli score order\n\n");printf(" 3:gaoshu score order\n \n");printf(" 4:ying yu score order\n\n");printf(" 5:tiyu score order\n\n");printf(" 6:average score order\n\n");printf(" 0:back menu\n\n");scanf("%d",&chioce);switch(chioce){case 1: grade_order();break;case 2: wuli_order();break;case 3: gaoshu_order();break;case 4: yingyu_order();break;case 5: tiyu_order();break;case 6: average_order();break;case 0:break;}}while(chioce!=0);}/**********answer secretory***********/mima_message(){int flag;char answer[10];char secret[10]="abcd";flag=2;do{system("cls");printf("\n______________________mi ma wei 'abcd'________________\n\n");printf("______________________qing shu ru mi ma:");scanf("%s",answer);getchar();if(strcmp(secret,answer)==0){flag=1;printf("\n\n =====throngh=====\n\n\n");printf("____________________press any key into next:\n");bioskey(0);}else{flag=0;printf("______________________input error:\n");printf("______________________press any key to return:\n");bioskey(0);}}while(flag!=1);}/*********read message****************/read_message(){int i;system("cls");if(sum<=0){ printf("without message\n");getch();return;}for(i=0;i<sum;i++){system("cls");print1;printf("\n%dth student's mssage\n",i+1);print1;printf("\n");PRINT0;PRINT1;PRINT2;printf("\n********press any key -show the next one********\n ");getch();}printf("________________totle num :%d________________\n",sum); printf("_____________press any key return______________\n"); bioskey(0);}/*************************************/main(){int chioce,flag;mima_message();do{system("cls");chioce=9;printf("**********************************************\n");printf("****welcome to system of managing students****\n");printf("**********************************************\n\n");printf("-------------------choose 0-8-----------------\n\n");printf(" 1:write message\n\n");printf(" 2:add message\n\n");printf(" 3:inqiure name\n\n");printf(" 4:change message\n\n");printf(" 5:insert message\n\n");printf(" 6:order message\n\n");printf(" 7:delete message\n\n");printf(" 8:read messaeg\n\n");printf(" 0:***exit***\n\n");scanf("%d",&chioce);getchar();switch(chioce){case 1: write_message();break;case 2: add_message();break;case 3: inqiure_message();break;case 4: change_message();break;case 5: insert_message();break;case 6: order_message();break;case 7: delete_message();break;case 8: read_message();break;case 0: printf("___sure press y/Y:___\n\n___no sure press n/N:___");scanf("%c",&chioce);getchar();if(chioce=='y'||chioce=='Y') flag=0;else flag=1;break;default : printf("\n ___input error___\n\n");printf("***press any key to go on***\n");getch();break;}}while(flag!=0);save_message();system("cls");printf("\n\n___message was saved___\n\n\n*****file name is student.txt*****\n");bioskey(0);}。
学生信息管理系统 C语言
/*********************************************************************** *************************学生信息管理系统(2)************************** *修复了在没有学生记录的情况下查看、排序和查询部分仍然显示出子菜单的问题* ************************************************************************/ #include <stdio.h>#include <string.h>#include <stdlib.h>#define N 50 //学生记录最大数量struct student //学生记录结构体定义{int ID;//学号char name[20];//姓名char sex[2];//性别int score[3];//三门课的成绩(高数,英语,专业课)int sum;//三门课的成绩和float average;//三门课的平均成绩};/*********************************************************************** ****************************进行函数声明******************************** ************************************************************************/ void Menu_select(); //显示主菜单void Inputstu(struct student stu[], int * stu_number); //录入学生信息void Browsestu(struct student stu[], int * stu_number); //查看学生信息void Sortstu(struct student stu[], int * stu_number); //排序学生信息void Searchstu(struct student stu[], int * stu_number); //查找学生信息void Deletestu(struct student stu[], int * stu_number); //删除学生信息void Modifystu(struct student stu[], int * stu_number); //修改学生信息void Countscore(struct student stu[], int * stu_number); //统计学生信息/*********************************************************************** ******************开始定义各个功能模块的函数**************************** ************************************************************************/ void Menu_seclect()//菜单选择函数部分{system("cls");system("title 主菜单");printf("\n\n");printf("\t\t|-----------------------------------|\n");printf("\t\t| 学生信息管理系统|\n");printf("\t\t|-----------------------------------|\n");printf("\t\t| 1---录入学生记录|\n");printf("\t\t| 2---查看学生记录|\n");printf("\t\t| 3---查询学生记录|\n");printf("\t\t| 4---排序学生记录|\n");printf("\t\t| 5---删除学生记录|\n");printf("\t\t| 6---修改学生记录|\n");printf("\t\t| 7---统计学生记录|\n");printf("\t\t| 0---【退出系统】|\n");printf("\t\t|-----------------------------------|\n");}void Inputstu(struct student stu[], int * stu_number)//1.增加学生记录函数部分{char ch = 'y';int i, count = 0;system("title 增加学生记录");while ((ch == 'y') || (ch == 'Y')){system("cls");printf("\n\t\t--------------------增加学生记录------------------\n");printf("\n\n\t\t 请输入学生信息\n");printf("\n\t\t 学号:");scanf("%d", &stu[count].ID);for (i = 0; i < *stu_number; i++)if (stu[count].ID == stu[i].ID){printf("\n\t\t 该学号已使用,请重输:\n");printf("\n\t\t 学号:");scanf("%d", &stu[count].ID);}printf("\n\t\t 姓名:");scanf("%s", &stu[count].name);printf("\n\t\t 性别:");scanf("\n%s", &stu[count].sex);printf("\n\t\t 数学成绩:");scanf("%3d", &stu[count].score[0]);printf("\n\t\t 英语成绩:");scanf("%3d", &stu[count].score[1]);printf("\n\t\t 专业成绩:");scanf("%3d", &stu[count].score[2]);stu[count].sum = stu[count].score[0] + stu[count].score[1] + stu[count].score[2];stu[count].average = (float)stu[count].sum / 3.0;printf("\n\n\t\t 是否输入下一个学生信息?(y/n)");scanf("\n%c", &ch);count++;}*stu_number = *stu_number + count;return;}void Browsestu(struct student stu[], int * stu_number)//2.浏览学生记录函数部分{int i, j, choose;struct student temp_stu[N], st;system("title 浏览学生记录");while (1){system("cls");printf("\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 浏览学生记录子菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 1---按学号顺序浏览|\n");printf("\t| 2---按名次顺序浏览|\n");printf("\t| 0---返回主菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t 请选择浏览方式:");scanf("%d", &choose);switch (choose){case 1:if(* stu_number==0){ printf("\t\t对不起,无可用的学生纪录!\n");getch();return;}else{system("cls");printf("\n\n\t 按学号升序浏览如下:\n");printf("\n\t 学号\t 姓名\t 性别\t数学\t英语\t专业\t总分\t平均分\n\n");for (i = 0; i < *stu_number; i++){printf("\t %d\t %s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);}printf("\n\t\t 浏览完毕,按任意键返回子菜单!");getch();break;}case 2:if(* stu_number==0){ printf("\t\t对不起,无可用的学生纪录!\n");getch();return;}else{for (i = 0; i < *stu_number; i++){temp_stu[i] = stu[i];}for (i = 1; i < *stu_number; i++)for (j = 1; j <= *stu_number - i; j++)if (temp_stu[j - 1].sum < temp_stu[j].sum){st = temp_stu[j - 1];temp_stu[j - 1] = temp_stu[j];temp_stu[j] = st;}system("cls");printf("\n\n\t 按名次升序浏览如下:\n");printf("\n\t名次\t学号\t姓名\t性别\t数学\t英语\t专业\t总分\t平均分\n");for (i = 0; i < *stu_number; i++){printf("\t %d\t%d\t%s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", i + 1, temp_stu[i].ID, temp_stu[i].name, temp_stu[i].sex, temp_stu[i].score[0], temp_stu[i].score[1], temp_stu[i].score[2], temp_stu[i].sum, temp_stu[i].average);}printf("\n\t\t 浏览完毕,按任意键返回子菜单!");getch();break;}case 0:return;}}return;}void Sortstu(struct student stu[], int * stu_number)//3.排序学生成绩记录函数部分{int i, j;struct student st;system("title 排序学生记录");if(* stu_number==0){ printf("\t\t对不起,无可用的学生纪录!\n");getch();return;}else{for (i = 1; i < *stu_number; i++)for (j = 1; j <= *stu_number - i; j++)if (stu[j - 1].ID > stu[j].ID){st = stu[j - 1];stu[j - 1] = stu[j];stu[j] = st;}system("cls");printf("\n\n\t\t********************排序学生记录********************\n");printf("\n\n\t 按学号升序排序后的学生记录如下:\n");printf("\n\t 学号\t姓名\t性别\t数学\t英语\t专业\t总分\t平均分\n\n");for (i = 0; i < *stu_number; i++){printf("\t %d\t%s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);}printf("\n\t\t 排序完毕,按任意键返回主菜单!");getch();return;}}void Searchstu(struct student stu[], int * stu_number)//4.查询学生记录函数部分{int xh,i, num, choose, find;char xm[20];system("title 查询学生记录");while (1){system("cls");printf("\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 查询学生记录子菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 1---按学号查询|\n");printf("\t| 2---按姓名查询|\n");printf("\t| 0---返回主菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t 请选择查询方式:");scanf("%d", &choose);switch (choose){case 1:if(* stu_number==0){printf("\t\t对不起,无可用的学生纪录!\n");getch();return;}else{printf("\n\t 请输入要查询的学生学号:");scanf("%d", &xh);for (i = 0; i < *stu_number; i++)if (stu[i].ID == xh){printf("\n\t 要查询的学生信息如下:\n");printf("\n\t 学号\t 姓名\t 性别\t数学\t英语\t专业\t总分\t平均分\n\n");printf("\t %d\t %s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);printf("\n\t 显示完毕,按任意键返回子菜单!");getch();break;}if (i == *stu_number){printf("\n\t 要查询的学生不存在!按任意键返回子菜单!");getch();}break;}case 2:if(* stu_number==0){printf("\t\t对不起,无可用的学生纪录!\n");getch();return;}else{printf("\n\t 请输入要查询的学生姓名:");scanf("%s", xm);find = 0;num = 0;for (i = 0; i < *stu_number; i++){if (strcmp(stu[i].name, xm) == 0){find = 1;num++;if (num == 1){printf("\n\t 要查询的学生信息如下:\n");printf("\n\t 学号\t 姓名\t 性别\t数学\t英语\t专业\t总分\t 平均分\n\n");}printf("\t %d\t %s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);}}if (find){printf("\n\t 显示完毕,按任意键返回子菜单!");getch();}else{printf("\n\t 要查询的学生不存在!按任意键返回子菜单!");getch();}break;}case 0:return;}}return;}void Deletestu(struct student stu[], int * stu_number)//删除学生记录函数部分{int i, j,xh;char ch = 'y';system("title 删除学生记录");while ((ch == 'y') || (ch == 'Y')){system("cls");printf("\n\t\t------------------------删除学生记录------------------------\n\n");printf("\t\t 请输入要删除的学生学号:");scanf("%d", &xh);for (i = 0; i < *stu_number; i++){if (stu[i].ID == xh){printf("\n\t 要删除的学生信息如下:\n");printf("\n\t 学号\t 姓名\t 性别\t数学\t英语\t专业\t总分\t平均分\n\n");printf("\t %d\t %s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);break;}}if (i == *stu_number){printf("\n\t\t要删除的学生不存在!\n");}else{printf("\n\t 确定删除吗(y/n)?:");scanf("\n%c", &ch);if (ch == 'y' || ch == 'Y'){for (j = i + 1; j < *stu_number; j++){stu[j - 1] = stu[j];}printf("\n\t 该学生已被删除!\n");(*stu_number)--;}}printf("\n\t 是否继续删除其他学生(y/n)?:");scanf("\n%c", &ch);}return;}void Modifystu(struct student stu[], int * stu_number)//修改学生记录函数部分{int i, j, choose,xh;char ch = 'y';system("title 修改学生记录");while (ch == 'y' || ch == 'Y'){system("cls");printf("\n\t --------------------------修改学生记录--------------------------\n\n");printf("\t 请输入要修改的学生学号:");scanf("%d", &xh);for (i = 0; i < *stu_number; i++){if (stu[i].ID == xh){printf("\n\t 要修改的学生信息如下:\n");printf("\n\t 学号\t 姓名\t 性别\t数学\t英语\t专业\t总分\t平均分\n\n");printf("\t %d\t %s\t %s\t %d\t %d\t %d\t %d\t %.2f\n\n", stu[i].ID, stu[i].name, stu[i].sex, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].sum, stu[i].average);break;}}if (i == *stu_number){printf("\n\t\t要修改的学生不存在!\n");}else{printf("\n\t 确定修改吗(y/n)?:");scanf("\n%c", &ch);while (ch == 'y' || ch == 'Y'){printf("\n\t 1.基本信息修改 2.学生成绩修改\n");printf("\n\t 请选择修改内容:");scanf("%d", &choose);switch (choose){case 1:system("cls");printf("\n\t\t-------------请重新输入该生的基本信息-----------\n");printf("\n\t\t 学号:");scanf("%d", &stu[i].ID);for (j = 0; j < *stu_number; j++)if (stu[i].ID != xh && stu[i].ID == stu[j].ID){printf("\n\t\t 该学号已存在,请重新输入!\n");printf("\n\t\t 学号:");scanf("%d", &stu[i].ID);}printf("\n\t\t 姓名:");scanf("%s", &stu[i].name);printf("\n\t\t 性别:");scanf("\n%s", &stu[i].sex);break;case 2:system("cls");printf("\n\t\t-------------请重新输入该生的成绩信息-----------\n");printf("\n\t\t 数学成绩:");scanf("%3d", &stu[i].score[0]);printf("\n\t\t 英语成绩:");scanf("%3d", &stu[i].score[1]);printf("\n\t\t 专业成绩:");scanf("%3d", &stu[i].score[2]);stu[i].sum = stu[i].score[0] + stu[i].score[1] + stu[i].score[2];stu[i].average = (float)stu[i].sum / 3.0;}printf("\n\t\t 修改成功!是否继续修改该生的其他信息(y/n)?:");scanf("\n%c", &ch);}}printf("\n\t\t 是否继续修改其他学生的信息(y/n)?:");scanf("\n%c", &ch);}return;}void Countscore(struct student stu[],int * stu_number)//统计学生成绩函数部分{int i, j, choose, sum[3], grade[3][5], min_score[3], max_score[3];float avg[3];system("title 统计学生成绩");while (1){system("cls");printf("\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 统计学生成绩子菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t| 1---统计每门课程的总分和平均分|\n");printf("\t| 2---统计每门课程的最高分和最低分|\n");printf("\t| 3---统计每门课程各分数段人数|\n");printf("\t| 0---返回主菜单|\n");printf("\t|---------------------------------------------------------------|\n");printf("\t 请选择统计方式:");scanf("%d", &choose);if (choose == 1){for (j = 0; j < 3; j++){sum[j] = 0;avg[j] = 0.0;}for (j = 0; j < 3; j++)for (i = 0; i < *stu_number; i++){sum[j] = sum[j] + stu[i].score[j];}for (j = 0; j < 3; j++){avg[j] = (float)sum[j] / *stu_number;}printf("\n\t 数学课程总分为:%d,平均分为:%.2f\n", sum[0], avg[0]);printf("\n\t 英语课程总分为:%d,平均分为:%.2f\n", sum[1], avg[1]);printf("\n\t 专业课程总分为:%d,平均分为:%.2f\n", sum[2], avg[2]);printf("\n\n\t 统计完毕,按任意键返回子菜单!\n");getch();}elseif (choose == 2){for (j = 0; j < 3; j++) //min_score[3]和max_score[3]数组初始化{min_score[j] = 0;max_score[j] = 0;}for (j = 0; j < 3; j++){if (*stu_number > 0){min_score[j] = max_score[j] = stu[0].score[j]; //最高分最低分置初值}else{min_score[j] = max_score[j] = 0;}for (i = 1; i < *stu_number; i++){if (stu[i].score[j] < min_score[j]){min_score[j] = stu[i].score[j];}if (stu[i].score[j] > max_score[j]){max_score[j] = stu[i].score[j];}}}printf("\n\t 数学课程的最低分:%d,最高分:%d\n", min_score[0], max_score[0]);printf("\n\t 英语课程的最低分:%d,最高分:%d\n", min_score[1], max_score[1]);printf("\n\t 专业课程的最低分:%d,最高分:%d\n", min_score[2], max_score[2]);printf("\n\n\t 统计完毕,按任意键返回子菜单!\n");getch();}elseif (choose == 3){for (i = 0; i < 3; i++)for (j = 0; j < 5; j++){grade[i][j] = 0;}for (j = 0; j < 3; j++)for (i = 0; i < *stu_number; i++){switch (stu[i].score[j] / 10){case 10:case 9:grade[j][0]++;break;case 8:grade[j][1]++;break;case 7:grade[j][2]++;break;case 6:grade[j][3]++;break;default:grade[j][4]++;break;}}printf("\n\n");printf("\t 数学课程各分数段的人数如下:\n");printf("\t 90-100: %d | 80-90: %d | 70-80: %d | 60-70: %d | 60分以下: %d\n\n", grade[0][0], grade[0][1], grade[0][2], grade[0][3], grade[0][4]);printf("\t 英语课程各分数段的人数如下:\n");printf("\t 90-100: %d | 80-90: %d | 70-80: %d | 60-70: %d | 60分以下: %d\n\n", grade[1][0], grade[1][1], grade[1][2], grade[1][3], grade[1][4]);printf("\t 专业课程各分数段的人数如下:\n");printf("\t 90-100: %d | 80-90: %d | 70-80: %d | 60-70: %d | 60分以下: %d\n\n", grade[2][0], grade[2][1], grade[2][2], grade[2][3], grade[2][4]);printf("\n\n\t 统计完毕,按任意键返回子菜单!\n");getch();}elseif (choose == 0){break; //结束循环}}return;}/*********************************************************************** *********************程序的主函数从这里开始运行************************* ************************************************************************/ int main(void){struct student stu[N];int stu_number=0;int choose,flag=1;system("color 1F");system("title 学生信息管理系统");while (flag){system("cls");Menu_seclect();printf("\t\t 请选择主菜单序号(0-7):");scanf("%d", &choose);switch (choose){case 1:Inputstu(stu, &stu_number);break;case 2:Browsestu(stu, &stu_number);break;case 3:Searchstu(stu, &stu_number);break;case 4:Sortstu(stu, &stu_number);break;case 5:Deletestu(stu, &stu_number);break;case 6:Modifystu(stu, &stu_number);break;case 7:Countscore(stu, &stu_number);break;case 0:system("cls");system("color 2F");printf("\n\n\n\n\n");printf("\t*****************************************************************\n") ;printf("\t*****************************************************************\n") ;printf("\t* * * *\n");printf("\t* * 感谢您的使用,再见! * *\n");printf("\t* * * *\n");printf("\t*****************************************************************\n") ;printf("\t*****************************************************************\n") ;flag = 0;}}}。
C语言 学生信息管理系统
float chinese;
float math;
float english;
float computer;
float ave;
float total;
}stu[100];
int count; /*全局变量,用于记录学生人数*/
#include<stdio.h>
#include<string.h>
#nclude<stdlib.h>
struct node{ /*学生各项信息*/
char name[10];
char number[10];
char sex[5];
for(i=1;i<=count;i++) /*写文本操作*/
fprintf(fp,"%1s %8s %6s %6.0f %8.1f %9.1f %8.1f %11.1f %9.1f %8.1f\n",stu[i].number,stu[i].name,stu[i].sex,stu[i].age,stu[i].chinese,stu[i].math,stu[i].english,stu[i].computer,stu[i].ave,stu[i].total);
scanf("%f",&stu[i].computer);
stu[i].total=stu[i].english+stu[i].computer+stu[i].chinese+stu[i].math; /*计算总成绩*/
stu[i].ave=stu[i].total/4; /*计算平均成绩*/
c语言-学生信息管理系统(完整版)
}
count=fwrite(stu,sizeof(Student),current,fs);
fclose(fs);
if(count!=current)
{
printf("保存失败\n");
return 1;
case'4':delete();break;
case'5':list();break;
case'6':save();break;
case'7':load();break;
case'0':if(stu!=NULL)
#include<string.h>
#include<malloc.h>
#include"Student.h"
#include"function.h"
Student*stu=NULL;
int current=0;
int total=0;
int main()
{
char choice;
printf("地址:%s\n",stu[i].address);
return 0;
}
}
printf("该学生不存在\n");
return 1;
}
int update()
{
char name[40];
printf(" 7.加载学生信息\n");
printf(" 0.退出程序\n");
C语言 学生信息管理系统(完整版)
电子科技大学成都学院程序综合设计论文论文题目学生信息管理系统学生姓名魏国学号1340840625专业机械设计制造及其自动化系(分院)电子工程系授课教师杜娥2015年12月制摘要随着经济的发展,社会的进步,计算机越来越深入到我们日常的工作学习及生活中,成为我们日常生活不可或缺的辅助工具。
随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已成为人们深刻认识,它已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。
现在由于学校规模进一步扩大,学生人数逐渐上升,在学校的学生信息管理中,虽然已经存在许多学生信息管理系统,但由于学校之间的管理差异很信息的不同,各个学校的学生信息管理的要求不一致,这样我们需要根据具体学习的具体要求来开发学生信息管理系统以方便学生管理。
本系统主要对学生各种信息进行处理。
本系统采用C语言编写,设计从实用性出发,设计开发出一个操作简单且符合实际需要的学生信息管理系统。
本文设计出一个可以添加、修改、查询、删除、统计的学生信息管理系统;最后,通过测试分析,力求将学到的只是在学生信息管理系统的得到全面运用,并使系统在实际的操作中能按照设计的要求安全有效的正确运行。
学生信息管理系统是为了实现学校对学生信息管理的系统化、规范化和自动化,从而提高学校管理效率而设计的。
它完全取代了原来一直用人工管理的工作方式,避免了由于管理人员的工作疏忽以及管理质量问题所造成的各种错误,为及时、准确、高效的完成学生信息管理提供了强有力的工具和管理手段。
学生信息管理系统是一个中小型数据库管理系统,它界面美观、操作简单、安全性高,基本满足了学生信息管理的要求。
学生信息管理系统在运行阶段,效果好,数据准确性高,提高了工作效率,同时也实现了学生信息管理计算机化。
关键字:学生信息,管理系统,数据库,C语言编写第一章系统功能和组成模块1.1系统功能学生信息管理系统存放了每个学生的学号,姓名,性别,年龄,出生年月,家庭住址,政治面貌等信息的数据库。
学生信息管理系统(C语言)
学⽣信息管理系统(C语⾔)#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct student{int id;char name[20];int age;char sex;char birthday[20];char address[20];char phone[15];char email[30];struct student *next;}student;student *head = NULL;int length;void create(){student *p1,*p2;length = 0;p1 = (student *)malloc(sizeof(student));p1->id = -1;if(head == NULL){head = p1;}printf("请输⼊学⽣的学号、姓名、年龄、性别、出⽣年⽉、地址、电话、电⼦邮箱:\n");while(1){p2 = (student *)malloc(sizeof(student));scanf("%d %s %d %c %s %s %s %s",&p2->id,p2->name,&p2->age,&p2->sex,&p2->birthday,&p2->address,p2->phone,p2->email);if(p2->id == 0){printf("链表创建完成!\n");break;}length ++;p1->next = p2;p2->next = NULL;p1 = p1->next;}return ;}void LoadStudentInFromFile(){student *p,*q;int c;FILE* f;f = fopen("input.txt","rb");if(f == NULL){return ;}fseek(f,0,SEEK_SET);p = (student *)malloc(sizeof(student));p->next = NULL;head = p;while(!feof(f)){c = fgetc(f);if(c != -1){fseek(f,-1,SEEK_CUR);}else{return ;}q = (student *)malloc(sizeof(student));fscanf(f,"%d",&q->id);fscanf(f,"%s",q->name);fscanf(f,"%d",&q->age);fscanf(f,"%c",&q->sex);fscanf(f,"%s",q->birthday);fscanf(f,"%s",q->address);fscanf(f,"%s",q->phone);fscanf(f,"%s",q->email);q->next = NULL;p->next = q;p = p->next;length ++;//链表长度}}void ModifyStudentInfo(){student *p = head->next;int num;printf("请输⼊要修改的学⽣的学号:");scanf("%d",&num);while(p != NULL){if(p->id == num){printf("修改前,学号为%d的学⽣信息如下:\n",num);printf("%d %s %d %c %s %s %s %s",p->id,p->name,p->age,p->sex,p->birthday,p->address,p->phone,p->email); printf("请输⼊学⽣的新电话:");getchar();gets(p->phone);printf("请输⼊学⽣的新地址:");gets(p->address);printf("修改后,学号为%d的学⽣信息如下:\n",num);printf("%d %s %d %c %s %s %s %s",&p->id,p->name,&p->age,p->sex,p->birthday,p->address,p->phone,p->email);return ;}p = p->next;}if(p == NULL){printf("该学号不存在!\n");return ;}}void display(){student *p = head->next;printf("链表中所有的学⽣信息如下:\n");while(p != NULL){printf("%d %s %d %c %s %s %s %s",p->id,p->name,p->age,p->sex,p->birthday,p->address,p->phone,p->email);printf("\n");p = p->next;}return ;}void search(){int num,x;char name[20];student *p = head->next;printf("请选择查询⽅式:\n");printf("1、按学号查询\t2、按姓名查询\n");scanf("%d",&x);if(x == 1){printf("需要查找的学⽣学号为:");scanf("%d",num);while(p != NULL){if(p->id == num){printf("学号为%d的学⽣信息如下:\n",num);printf("%d %s %d %c %s %s %s %s",p->id,p->name,p->age,p->sex,p->birthday,p->address,p->phone,p->email);return ;}p = p->next;}if(p == NULL){printf("⽆此记录!\n");}}else if(x == 2){printf("需要查找的学⽣姓名为:");getchar();gets(name);p = head->next;while(p != NULL){if(strcmp(p->name,name) == 0){printf("学⽣姓名为%s的学⽣信息如下:\n",name);printf("%d %s %d %c %s %s %s %s",p->id,p->name,p->age,p->sex,p->birthday,p->address,p->phone,p->email);return ;}p = p->next;}if(p == NULL){printf("⽆此记录!\n");}}return ;}void insert(){int num,i;student *p,*q;p = head;printf("请输⼊你要插⼊的位置:");scanf("%d",&num);if(num > length){printf("找不到插⼊的位置\n");return ;}else{printf("请输⼊你要插⼊的学⽣的信息:\n");q = (student *)malloc(sizeof(student));scanf("%d %s %d %c %s %s %s %s",&q->id,q->name,&q->age,&q->sex,q->birthday,q->address,q->phone,q->email);while(p != NULL){if(p->id == q->id){printf("该学号已经存在,⽆法插⼊!\n");return ;}p = p->next;}p = head;for(i=0; i<num; ++i){p = p->next;}q->next = p->next;p->next = q;length ++;printf("插⼊成功!\n");return ;}}void Delete(){int num;student *p,*q;q = head;p = head->next;printf("请输⼊要删除的学⽣的学号:\n");scanf("%d",&num);while(p != NULL){if(p->id == num){q->next = p->next;free(p);length --;printf("删除成功!\n");return ;}p = p->next;q = q->next;}if(p == NULL){printf("找不到要删除的编号!\n");return ;}}void menu(){printf("___________________________________________________\n"); printf("| 学⽣信息管理系统 |\n");printf("| 0、退出系统 |\n");printf("| 1、录⼊学⽣信息 |\n");printf("| 2、建⽴链表 |\n");printf("| 3、显⽰链表 |\n");printf("| 4、查找链表中的某个元素 |\n");printf("| 5、删除链表中指定学号的结点 |\n");printf("| 6、指定位置上插⼊⼀个新结点 |\n");printf("| 7、修改学⽣信息 |\n");printf("__________________________________________________\n"); return ;}int main(void){int a;menu();while(1){printf("请输⼊相应的功能:");scanf("%d",&a);switch(a){case0:return0;case1:LoadStudentInFromFile();menu();break;case2:create();menu();break;case3:if(head){display();menu();}else{printf("链表为空,请先建⽴链表!\n");menu();}break;case4:if(head){search();menu();}else{printf("链表为空,请先建⽴链表!\n");menu();}break;case5:if(head){Delete();menu();}else{printf("链表为空,请先建⽴链表!\n");menu();}break;case6:if(head){insert();menu();}else{printf("链表为空,请先建⽴链表!\n");menu();}break;case7:if(head){ModifyStudentInfo();menu();}else{printf("链表为空,请先建⽴链表!\n"); menu();}break;default:break;}}system("pause");return0;}。
C语言版-学生信息管理系统
p1=head;
while(num!=p1->num&&p1->next!=NULL)/*p1不是要找的结点,并且后面还有结点*/
{p2=p1;p1=p1->next;}/*p1后移一个结点,p2的next指向了原来的P1*/
scanf("%d",&q);
return q;
}
struct stu *cr(struct stu *head,struct stu *stud) /*插入函数*/
{
struct stu *p0,*p1,*p2;
p1=head;/*让P1指向第一个结点*/
p0=stud;/*P0指向要插入的结点*/
p2=p1;/*P2成为了P1,现在的P2也就相当于刚才的首结点的next*/
p1=(struct stu *)malloc(sizeof(struct stu));/*给P1继续开辟新的内存单元*/
scanf("%ld,%s,%c,%f",&p1->num,&p1->name,&p1->sex,&p1->cj);/*继续输入剩余的学生信息,直到p1->num=0结束*/
while(p1->num!=0)
{
n=n+1; /*结点个数加1*/
if(n==1)head=p1;/*如果只有一个结点,那么首结点就是p1*/
else
p2->next=p1;/*否则P2成了首结点P2的next就成了p1*/
学生信息管理系统c语言数据结构
学生信息管理系统c语言数据结构以下是一个基于C语言的数据结构实现的学生信息管理系统示例:```cinclude <>include <>include <>// 定义学生结构体struct Student {char name[20];int age;int id;};// 定义学生信息管理系统结构体struct StudentSystem {struct Student students[100]; // 学生数组int count; // 学生数量};// 初始化学生信息管理系统void initStudentSystem(struct StudentSystem system) {system->count = 0;}// 添加学生信息void addStudent(struct StudentSystem system, char name, int age, int id) {if (system->count >= 100) {printf("学生数量已达上限!\n");return;}system->students[system->count].name[0] = '\0';strcpy(system->students[system->count].name, name);system->students[system->count].age = age;system->students[system->count].id = id;system->count++;}// 查询学生信息void queryStudent(struct StudentSystem system, int id) {for (int i = 0; i < system->count; i++) {if (system->students[i].id == id) {printf("学生姓名:%s,年龄:%d\n", system->students[i].name, system->students[i].age);return;}}printf("未找到该学生!\n");}// 显示所有学生信息void showAllStudents(struct StudentSystem system) {for (int i = 0; i < system->count; i++) {printf("学生姓名:%s,年龄:%d,学号:%d\n", system->students[i].name, system->students[i].age, system->students[i].id); }}// 测试代码int main() {struct StudentSystem system;initStudentSystem(&system); // 初始化学生信息管理系统 addStudent(&system, "张三", 20, 1001); // 添加学生信息 addStudent(&system, "李四", 21, 1002); // 添加学生信息 showAllStudents(&system); // 显示所有学生信息queryStudent(&system, 1002); // 查询学生信息return 0;}```。
学生信息管理系统C语言
学生信息管理系统C语言------------------------------------------作者------------------------------------------日期✁♓⏹♍●◆♎♏♦♦♎●♓♌♒✁♓⏹♍●◆♎♏♦♦❒♓⏹♑♒✁♎♏♐♓⏹♏ ✌✠♉❆✞☜☠❆ 最大学生数✁♎♏♐♓⏹♏ ✌✠♉✞☜ 最大课程数✁♎♏♐♓⏹♏ ✌✠♉ 最大选课门数♦⍓☐♏♎♏♐ ♦♦❒◆♍♦ 定义学生结构体类型♓⏹♦ ♦⏹☐ 学生学号♍♒♋❒ ♦⏹♋❍♏☯ 姓名♍♒♋❒ ♦♦♏⌧☯ 性别♓⏹♦ ♦♋♑♏ 年龄♍♒♋❒ ♦♋♎♎❒♏♦♦☯ 住址♍♒♋❒ ♦♎♏☐♦☯ 所在院系❝♦◆♎♏⏹♦♦⍓☐♏♎♏♐ ♦♦❒◆♍♦ 定义课程结构体类型♓⏹♦ ♍⏹☐ 课程号♍♒♋❒ ♍⏹♋❍♏☯ 课程名♓⏹♦ ♍❒♏♎♓♦ 学分❝☐◆❒♦♏♦⍓☐♏♎♏♐ ♦♦❒◆♍♦ 定义选课结构体类型♓⏹♦ ♦⏹☐ 学号♓⏹♦ ♍⏹☐ 课程号♓⏹♦ ♑❒♋♎♏ 成绩❝♏●♏♍♦♏♎♉♍☐◆❒♦♏定义学生顺序表类型♦⍓☐♏♎♏♐ ♦♦❒◆♍♦♦◆♎♏⏹♦ ♎♋♦♋☯✌✠♉❆✞☜☠❆♓⏹♦ ●♋♦♦♉♦♦◆♎♏⏹♦❝♏❑●♓♦♦♉♦♦◆♎♏⏹♦定义课程顺序表♦⍓☐♏♎♏♐ ♦♦❒◆♍♦☐◆❒♦♏ ♎♋♦♋☯✌✠♉✞☜♓⏹♦ ●♋♦♦♉♍☐◆❒♦♏定义选课信息顺序表♦⍓☐♏♎♏♐ ♦♦❒◆♍♦♏●♏♍♦♏♎♉♍☐◆❒♦♏ ♎♋♦♋☯✌✠♉♓⏹♦ ●♋♦♦♉♦♍❝♏❑●♓♦♦♉♦♍初始化学生顺序表♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ✋⏹♓♦♉♏❑●♓♦♦♉♦♦◆♎♏⏹♦☎✆初始化课程顺序表♏❑●♓♦♦♉♍☐◆❒♦♏✉ ✋⏹♓♦♉♏❑●♓♦♦♉♍☐◆❒♦♏☎✆初始化选课顺序表♏❑●♓♦♦♉♦♍✉ ✋⏹♓♦♉♏❑●♓♦♦♉♦♍☎✆在学生顺序表中第♓个位置插入一个新元素,成功返回 ,失败返回♓⏹♦ ✋⏹♦♏❒♦♉♦♦◆♎♏⏹♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉☹♉♦◆♓⏹♦ ♓♦◆♎♏⏹♦ ♦♦◆✆显示第♓个学生的信息 如果♓,显示所有学生信息,如果♓✌✠♉❆✞☜☠❆则显示指定位置上的学生信息,否则,提示输入的学生位置不合法❖☐♓♎ ♓♦☐●♋⍓♉♦♦◆♎♏⏹♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ☹♉♦◆♓⏹♦ ♓✆从文本文件中创建学生顺序表♓⏹♦ ❒♏♋♦♏♉♦◆♎♏⏹♦♉♏❑●♓♦♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ☹♉♦◆♍♒♋❒✉●♓●♏⏹♋❍♏✆初始化选课顺序表 返回指向学生顺序表的地址♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ✋⏹♓♦♉♏❑●♓♦♦♉♦♦◆♎♏⏹♦☎✆♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ☹♉♦◆为学生顺序表分配存储空间☹♉♦◆ ☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉✆❍♋●●☐♍☎♦♓♏☐♐☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✆✆♓♐☎☹♉♦◆ ✐ ☠✞☹☹✆ 如果分配成功☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦ ❒♏♦◆❒⏹ ☹♉♦◆♏●♦♏ 分配失败❒♏♦◆❒⏹ ☠✞☹☹❝❝在学生顺序表中第♓个位置插入一个新元素,成功返回 ,失败返回♓⏹♦ ✋⏹♦♏❒♦♉♦♦◆♎♏⏹♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉☹♉♦◆♓⏹♦ ♓♦◆♎♏⏹♦ ♦♦◆✆♓⏹♦ 判断顺序表是否满♓♐ ☎☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦ ✌✠♉❆✞☜☠❆✆☐❒♓⏹♦♐☎✂学生表已满,不能插入✐⏹✂✆❒♏♦◆❒⏹ ❝将下标位置●♋♦♦到♓的元素分别向后移动一个位置♐☐❒ ☎ ☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦ ♓ ✆☹♉♦◆♎♋♦♋☯ ☹♉♦◆♎♋♦♋☯插入新元素☹♉♦◆♎♋♦♋☯ ♦♦◆☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦表长 ❒♏♦◆❒⏹ ❝在学生顺序表中第♓个位置插入一个新元素,成功返回 ,失败返回♓⏹♦ ✋⏹♦♏❒♦♉♦♦◆♎♏⏹♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉☹♉♦◆♓⏹♦ ♓♦◆♎♏⏹♦ ♦♦◆✆显示第♓个学生的信息 如果♓,显示所有学生信息,如果♓✌✠♉❆✞☜☠❆则显示指定位置上的学生信息,否则,提示输入的学生位置不合法❖☐♓♎ ♓♦☐●♋⍓♉♦♦◆♎♏⏹♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ☹♉♦◆♓⏹♦ ♓✆♓⏹♦ ♓♐ ☎ ☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦✐✆♓♐☎♓ ✆输出所有学生信息☐❒♓⏹♦♐☎✂学号 ♦姓名 ♦性别 ♦年龄 ♦家庭住址 ♦所在院系⏹✂✆♐☐❒☎ ☹♉♦◆●♋♦♦♉♦♦◆♎♏⏹♦ ✆☐❒♓⏹♦♐☎✂♎♦♦♦♦♦♎♦♦♦♦⏹✂☹♉♦◆♎♋♦♋☯ ♦⏹☐☹♉♦◆♎♋♦♋☯♦⏹♋❍♏☹♉♦◆♎♋♦♋☯♦♦♏⌧☹♉♦◆♎♋♦♋☯♦♋♑♏☹♉♦◆♎♋♦♋☯♦♋♎♎❒♏♦♦☹♉♦◆♎♋♦♋☯♦♎♏☐♦✆❝♏●♦♏ ♓♐☎♓✌✠♉❆✞☜☠❆✆☐❒♓⏹♦♐☎✂♎♦♦♦♦♦♎♦♦♦♦⏹✂☹♉♦◆♎♋♦♋☯♓♦⏹☐☹♉♦◆♎♋♦♋☯♓♦⏹♋❍♏☹♉♦◆♎♋♦♋☯♓♦♦♏⌧☹♉♦◆♎♋♦♋☯♓♦♋♑♏☹♉♦◆♎♋♦♋☯♓♦♋♎♎❒♏♦♦☹♉♦◆♎♋♦♋☯♓♦♎♏☐♦✆❝♏●♦♏☐❒♓⏹♦♐☎✂指定的位置参数不合法,重新选择✐⏹✂✆❝❝♏●♦♏☐❒♓⏹♦♐☎✂学生表为空✐⏹✂✆❝❝从文本文件中创建学生顺序表♓⏹♦ ❒♏♋♦♏♉♦◆♎♏⏹♦♉♏❑●♓♦♦☎♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉ ☹♉♦◆♍♒♋❒✉●♓●♏⏹♋❍♏✆☞✋☹☜✉♐♓⏹定义文件指针♓⏹♦ ♓♓⏹♦ ♐♓⏹♓♦♒♏♎ ♓⏹♦ ♦⏹☐♦♦◆♎♏⏹♦ ♦♦◆打开学生信息表的文件♓♐☎☎♐♓⏹ ♐☐☐♏⏹☎♐♓●♏⏹♋❍♏✂❒✂✆✆☠✞☹☹✆❒♏♦◆❒⏹ ❝♦♒♓●♏☎✐♐♓⏹♓♦♒♏♎✆♐♦♍♋⏹♐☎♐♓⏹✂♎✂♦⏹☐✆♓♐☎♦⏹☐ ✐ ✆♦♦♓♦⏹☐ ♦⏹☐♐♦♍♋⏹♐☎♐♓⏹✂♦♦♎♦♦⏹✂♦♦◆♦⏹♋❍♏♦♦◆♦♦♏⌧ ♦♦◆♦♋♑♏♦♦◆♎♋♋❒♏♦♦♦♦◆♦♎♏☐♦✆♓✋⏹♦♏❒♦♉♦♦◆♎♏⏹♦☎☹♉♦◆♓♦♦◆✆❝♏●♦♏♐♓⏹♓♦♒♏♎ ❝❝❒♏♦◆❒⏹ ❝❖☐♓♎ ❍♋♓⏹☎✆♏❑●♓♦♦♉♦♦◆♎♏⏹♦✉☹♉♦♦◆♎♏⏹♦☹♉♦♦◆♎♏⏹♦ ✋⏹♓♦♉♏❑●♓♦♦♉♦♦◆♎♏⏹♦☎✆初始化学生顺序表♓♦☐●♋⍓♉♦♦◆♎♏⏹♦☎☹♉♦♦◆♎♏⏹♦✆♓♐ ☎❒♏♋♦♏♉♦◆♎♏⏹♦♉♏❑●♓♦♦☎☹♉♦♦◆♎♏⏹♦✂♦♦◆♎♏⏹♦ ♦⌧♦✂✆ ✆♎♓♦☐●♋⍓♉♦◆♎♏⏹♦☎☹♉♦♦◆♎♏⏹♦✆❝❝。
C语言学生信息管理系统
制作:李洋 班级:HT1119
自我介绍: 我叫李洋,山东淄博人,在烟台上大 学,大四没毕业我是学软件工程的
项目介绍: 项目名称是学生信息管理系统, 是用C语言在linux系统gcc 和gdb 环境下开发的
文件系统
menu.h:菜单函数头文件 student.h:功能函数头文件 main.c:主函数 menu.c:菜单文件 student.c:功能函数文件
信息录入
学号唯一,系统自动累加,将学生信息根据提 示输入,系统将密码进行恺撒加密后存储于链表当中; 系统会对输入的数据检查,如果长度过长或者数据 超出范围则给出相应的提示并要求从新输入
信息删除
输入要删除的学号,系统查找该学生信息并提示 是否删除,是,则删除并提示删除成功.
信息修改
输入要修改的学生学号并按提示修改
学生登陆
管理员应用操作
学生应用操作
结束
修 改
输入修 改信息
信息
否
规则
是
保存
继续
否
修改
是
结束
登陆模块
程序运行进入登陆页面,选择管理员登陆和学 生登陆,输入帐号密码进入程序菜单,输入密码 帐号错误三次之后程序自动结束!
管理员功能菜单
输入相应的数字进行不同的操作
makefile:编译文件 Int.dat:存储学号 pwd.dat:存储管理员密码 stu.dat:存储学生信息
模块图
学生信息管理系统
录入 遍历 删除 修改
重置
加载
查找
保存
按学号 按名次 按分数
按姓名 按名次 按班级
功能图
管理员
学生
录入
删除
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
学生信息管理系统c语言版/*头文件*/#include <stdio.h>#include <stdlib.h> /*引入动态存储分配函数库*/#include <conio.h> /*引入输入输出函数库*/#include <string.h> /*引入字符和字符串函数库*//*定义常数名*/#define MAXNUM 70 /*定义最大学生记录数*/#define MAXSUB 4 /*定义最大科目数*//*定义学生结构变量*/typedef struct stu /*定义学生结构体*/{char nu[15]; /*定义学号数组*/char cl[10]; /*定义班级数组*/ char name[20]; /*定义姓名数组*/char sex[3]; /*定义性别数组*/ int score[MAXSUB]; /*定义科目数组*/int sum; /*定义总成绩变量*/float average; /*定义平均成绩变量*/}student; /*定义一个学生结构体变量student*/int menu_select();void initialize(student * []);void input(student * []);void editmenu(student * []);void add_record(student * []);void delete_record(student * []);student * edit_record(student * []);void search_select(student *[]);student * name_search(student * []);student * nu_search(student * []);void total(student * []);void save(student * []); /*数据导出*/void load(student * []);void output(student * []);void gra_search(student * []);void lar_search(student * []);void main(){student * p; /*保存单个学生信息*/student * stuArray[MAXNUM]; /*保存所有学生信息的数组*/p=(student * )malloc(sizeof(student)); /*创建一个空的学生记录*/stuArray[0]=p; /*将该学生信息放入数组第一个位置*/printf("欢迎使用学生成绩管理系统(请按回车键继续!)......\n"); /*输出提示信息*/getch(); /*接收键盘按键*/for(; ; ){switch(menu_select()){case 1:system("cls"); /*选择选项1*/initialize(stuArray); /*数据初始化*/break;case 2:system("cls"); /*选择选项2*/input(stuArray); /*录入数据*/break;case 3: /*选择选项3*/system("cls");editmenu(stuArray); /*数据编辑*/break;case 4: /*选择选项4*/system("cls");total(stuArray); /*数据统计*/getch();break; /*跳出,重新进行菜单选择*/case 5: /*选择选项5*/system("cls");search_select(stuArray); /*数据查询*/getch();break;case 6: /*选择选项6*/system("cls");load(stuArray); /*数据导出*/break; /*跳出,重新进行菜单选择*/case 7: /*选择选项7*/system("cls");output(stuArray); /*数据显示*/save(stuArray); /*数据导出*/printf("导出成功!\n");getch();break; /*跳出,重新进行菜单选择*/case 0: /*选择选项0*/system("cls");printf("\n\n\n\n\t\t\t\t^_^感谢您使用本系统!\n");getch();exit(0); /*退出系统*/}}return; /*退出应用程序*/}/************************************************************************/int menu_select(){int menuItem=-1;system("cls");printf("\n\n\n\n\n");/*输出开始菜单界面*/printf(" |****************学生成绩管理系统****************| \n");printf(" |------------------------------------------------| \n");printf(" | 主菜单项| \n");printf(" |------------------------------------------------| \n");printf(" | 1---初始化| \n");printf(" | 2---数据录入| \n");printf(" | 3---数据编辑| \n");printf(" | 4---数据统计| \n");printf(" | 5---数据查询| \n");printf(" | 6---数据导入| \n");printf(" | 7---数据导出| \n");printf(" | 0---退出系统| \n");printf(" |------------------------------------------------| \n");printf("\n 请输入菜单项数字(0~7)(第一次进入系统请先初始化!):");do /*进入菜单选择循环*/{scanf("%d",&menuItem);if((menuItem<0)||(menuItem>7)){puts("输入有误,请重新输入:");}}while((menuItem<0)||(menuItem>7));return menuItem;}void initialize(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/for(i=0;i<MAXNUM;i++) /*查找每一个学生记录*/{stuArray[i]=NULL; /*初始化当前学生记录为空记录*/}printf("记录已经初始化!\n按任意键继续!");getch();return; /*结束初始化函数并返回主菜单*/}/************************************************************************/void input(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/int j=0; /*学生功课号*/int s=0; /*总成绩*/char c;for(i=0;i<MAXNUM;i++) /*对学生信息数组中的每条记录进行循环*/{s=0;stuArray[i]=(student * )malloc(sizeof(student));if(stuArray[i]==NULL){printf("分配内存失败!");getch();return;}do{printf("目前容量可以存储%d条记录,继续请输入y or Y,返回请输入n or N!\n",MAXNUM-i);c=getch();if(c=='y'||c=='Y')break;else if(c=='n'||c=='N'){stuArray[i] = NULL;return;}else printf("输入错误!请重新输入\n");}while(c!='y'&&c!='Y'&&c!='n'&&c!='N');printf("请输入第%d位同学学号(共12位):",i+1); /*提示输入学号*/scanf("%s",&stuArray[i]->nu); /*接收输入的学号*/printf("请输入第%d位同学班级:",i+1); /*提示输入班级*/scanf("%s",&stuArray[i]->cl); /*接收输入的班级*/printf("请输入第%d位同学姓名:",i+1); /*提示输入姓名*/scanf("%s",&stuArray[i]->name); /*接收输入的姓名*/printf("请输入学生性别:"); /*提示输入性别*/scanf("%s",&stuArray[i]->sex); /*接收输入的性别*/printf("请输入%d门成绩:\n",MAXSUB); /*提示输入成绩*/for(j=0;j<MAXSUB;j++){do{printf("课程%d成绩(语文为1,数学为2,英语为3,政治为4):",j+1); /*提示输入的是第几门课程成绩*/scanf("%d",&stuArray[i]->score[j]); /*接收成绩*/fflush(stdin); /*刷新内存缓冲区*/if((stuArray[i]->score[j]>100)||(stuArray[i]->score[j]<0))/*检查输入的成绩是否在要求范围内*/{printf("错误数据!请重新输入\n"); /*提示出错*/}s+=stuArray[i]->score[j]; /*临时统计总成绩*/}while((stuArray[i]->score[j]>100)||(stuArray[i]->score[j]<0));stuArray[i]->sum=s; /*保存当前学生的总成绩*/stuArray[i]->average=s/MAXSUB; /*算出当前学生的平均成绩*/}}return; /*结束函数*/}/************************************************************************/void editmenu(struct stu *stuArray[MAXNUM]){int menuitem=-1;printf("\n\n\n");printf("\t|---------------*********----------**********---------------|\n");printf("\t|---------------*********编辑子菜单**********---------------|\n");printf("\t|---------------*********----------**********---------------|\n");printf("\t| 1---增加记录|\n");printf("\t| 2---删除记录|\n");printf("\t| 3---修改记录|\n");printf("\t| 4---返回主菜单|\n");printf("\t|---------------*********----------**********---------------|\n");do{printf("\n\t请输入菜单项数字(1~4):");scanf("%d",&menuitem);}while((menuitem<1) || (menuitem>4));switch(menuitem){case 1:add_record(stuArray);break;case 2:delete_record(stuArray);break;case 3:edit_record(stuArray);break;case 4:return;}return;}/************************************************************************/void add_record(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/int j=0; /*科目号*/student * info; /*临时保存当前学生的信息*/int s=0; /*临时保存总成绩*/system("cls");/*搜查最新记录*/for(i=0;i<MAXNUM;i++) /*对学生信息数组中的每条记录进行循环*/{if(stuArray[i]==NULL) /*当前记录是空记录*/{break;}}if(i==MAXNUM) /*学生信息数组是否存满*/{printf("该组已经存满!");getch(); /*提示用户数组满了*/return;}info=(student * )malloc(sizeof(student)); /*为新记录创建一个保存空间*/if(info==NULL) /*创建保存空间是否成功*/{printf("\n内存不足!");getch(); /*不成功就提示用户没有足够内存创建记录空间*/return;}printf("输入学号:"); /*提示输入学号*/scanf("%s",&info->nu); /*接收输入的学号*/printf("请输入第%d位同学班级:",i+1); /*提示输入班级*/scanf("%s",&info->cl); /*接收输入的班级*/printf("请输入第%d位学生姓名:",i+1); /*提示输入姓名*/scanf("%s",&info->name); /*接收输入的姓名*/printf("请输入学生性别:"); /*提示输入性别*/scanf("%s",&info->sex); /*接收输入的性别*/printf("请输入%d门成绩\n",MAXSUB); /*提示输入成绩*/for(j=0;j<MAXSUB;++j) /*对各科目进行循环*/{do /*开始循环输入成绩*/{printf("科目%d成绩(语文为1,数学为2,英语为3,政治为4)",j+1);/*提示当前输入的是第几科成绩*/scanf("%d",&info->score[j]); /*接收输入的成绩*/if((info->score[j]>100) || (info->score[j]<0)) /*输入的成绩是否在范围内*/{printf("错误数据,请重新输入\n");getch();}}while((info->score[j]>100) || (info->score[j]<0));s+=info->score[j]; /*临时统计总成绩*/}info->sum=s; /*保存当前学生的总成绩*/info->average=s/MAXSUB; /*算出当前学生的平均成绩*/stuArray[i]=info; /*将当前学生的信息存入学生信息数组*/}/************************************************************************/void delete_record(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/int j=0; /*科目号*/char s[11]; /*学号*/char c; /*确认指令Y 删除N不删除*/system("cls");printf("\n请输入要删除的学生学号:"); /*提示输入学生学号*/scanf("%s",&s); /*接收输入的学号*/j=i+1;for(i=0;i<MAXNUM && stuArray[i]!=NULL;i++) /*对学生信息数组中每条学生记录进行循环*/{if(strncmp(stuArray[i]->nu,s,11)==0) /*学生信息数组中是否存在与用户输入学号相同的学生*/{printf("\n存在要删除的学生记录!");getch(); /*找到指定学号的学生记录*/break;}}if((i==MAXNUM)||(stuArray[i]==NULL)) /*是否找遍数组中的所有记录*/{printf("\n不存在要删除的学生记录!");getch(); /*没有找到与指定学号相同的学生*/return;}/*输出要删除的学生信息开始*/printf("\n********------------**********这是要删除的记录吗?**********------------********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|-----------|------|------|------|------|------|------|------|--------|------|\n");printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%6d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("\n********------------**********这是要删除的记录吗?**********------------********\n");/*输出要删除的学生信息结束*/printf("你确定要删除该记录吗?Y or N!\n"); /*提示确认删除*/scanf("%s",&c);if((c=='Y')||(c=='N')) /*接收删除指令*/{for(j=i+1;j<MAXNUM-i;j++) /*从当前删除记录位置到最后一个记录循环*/{stuArray[j-1]=stuArray[j]; /*将记录向上移动一行*/}stuArray[j]=NULL;printf("正在删除......\n");printf("\n.......已经删除学号为%s的学生记录......\n",s);}else /*不删除*/{editmenu(stuArray); /*返回编辑子菜单*/}}/************************************************************************/ student * edit_record(student * stuArray[MAXNUM]){int i=0; /*学生记录行数*/int j=0; /*科目数*/int m=0; /*修改状态标志0不修改*/int sum=0; /*总成绩*/ char s[11]; /*学号*/char c; /*确认指令Y 修改N不修改*/system("cls");printf("\n请输入要修改的学生学号:"); /*提示输入学号*/scanf("%s",&s); /*接收输入的学号*/for(i=0;(i<MAXNUM) && (stuArray[i]!=NULL);i++) /*对学生信息数组中的每条学生记录进行循环*/{if(strncmp(stuArray[i]->nu,s,11)==0) /*学生信息数组中是否存在与输入的学号相同的学生*/{printf("\n存在要修改的学生记录!");getch(); /*找到指定的学生记录*/break; /*跳出循环,不再查找*/}}if((i==MAXNUM) || (stuArray[i]==NULL)) /*是否找遍数组所有记录*/{printf("\n不存在要修改的学生记录!");getch(); /*没有找到指定的学生记录*/return NULL; /*返回菜单选择界面*/}/*开始修改学生信息*/printf("\n********------------**********这是要修改的记录吗?**********------------********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|-----------|------|------|------|------|------|------|------|--------|------|\n");printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%6d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("\n********------------**********这是要修改的记录吗?**********------------********\n");/*结束修改学生信息*/printf("你确定要修改该记录吗?Y or N\n"); /*提示确认修改*/scanf("%s",&c); /*接收确认指令*/if((c=='Y') || (c=='y')) /*确认修改*/ {m=1; /*修改状态标志为1确认修改*/}else /*不修改*/{editmenu(stuArray); /*返回编辑子菜单*/}while(m==1) /*确认修改*/{printf("要修改哪个科目的成绩(语文为1,数学为2,英语为3,政治为4)\n");/*输出修改科目编号的询问*/scanf("%d",&j); /*接收修改科目的编号*/do /*进入科目修改循环*/{printf("科目%d成绩",j); /*提示当前修改的是哪个科目成绩*/scanf("%d",&stuArray[i]->score[j-1]); /*接收新的成绩*/if((stuArray[i]->score[j-1]>100) || (stuArray[i]->score[j-1]<0))/*输入的成绩是否在范围中*/{printf("错误数据,请重新输入!\n"); /*提示输入的成绩有误*/}}while((stuArray[i]->score[j-1]>100) || (stuArray[i]->score[j-1]<0));/*输入的成绩是否在范围内*/for(j=0;j<MAXSUB;j++) /*对当前学生每个科目进行循环*/{sum+=stuArray[i]->score[j]; /*临时统计当前学生总成绩*/}stuArray[i]->average=sum/MAXSUB; /*计算当前学生的平均成绩*/printf("还要继续修改此记录吗?Y or N!\n"); /*提示是否继续修改*/scanf("%s",&c); /*接收确认指令*/if((c=='Y') || (c=='y')) /*确认指令*/{m=1; /*修改状态标志为1确认修改*/}else /*不修改*/{break; /*跳出确认循环*/}}return stuArray[i]; /*返回修改后的学生记录*/}/************************************************************************/void search_select(struct stu *stuArray[MAXNUM]){int menuitem=-1;printf("\n\n\n");printf("\t|---------------*********----------**********---------------|\n");printf("\t|---------------*********查询子菜单**********---------------|\n");printf("\t|---------------*********----------**********---------------|\n");printf("\t| 1---学号查询|\n");printf("\t| 2---姓名查询|\n");printf("\t| 3---分数段查询|\n");printf("\t| 4---成绩顺序查询|\n");printf("\t| 5---返回主菜单|\n");printf("\t|---------------*********----------**********---------------|\n");do{printf("\n\t请输入菜单项数字(1~3):");scanf("%d",&menuitem);}while((menuitem<1) || (menuitem>5));switch(menuitem){case 1:nu_search(stuArray);break;case 2:name_search(stuArray);break;case 3:gra_search(stuArray);break;case 4:lar_search(stuArray);case 5:return;}return;}/************************************************************************/ student * nu_search(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/char s[12]; /*学号*/char c;system("cls");printf("\n请输入要查询的学生的学号:"); /*提示输入学号*/scanf("%s",&s); /*接收输入的学号*/for(i=0;i<MAXNUM&&stuArray[i]!=NULL;i++) /*对学生信息数组中的每条学生记录进行循环*/{if(strncmp(stuArray[i]->nu,s,11)==0) /*学生信息数组中是否存在与收入的学号相同的记录*/{printf("\n存在要查询的学生记录!"); getch(); /*找到了指定的记录*/break; /*跳出循环,不再查找*/}}if((i==MAXNUM) || (stuArray[i]==NULL)) /*是否找遍数组中所有的记录*/{printf("\n不存在要查询的学生记录!");getch(); /*没有找到指定的记录*/return NULL; /*返回菜单选择界面*/}/*输出要查询的学生信息开始*/printf("\n********------------**********这是要查询的记录吗?**********------------********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|------------|------|------|------|------|------|------|------|--------|------|\n");printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%6d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("\n********------------**********这是要查询的记录吗?**********------------********\n");/*输出要查询的学生信息结束*/do{printf("返回请输入b or B!\n");scanf("%s",&c);if(c=='b'||c=='B')return NULL;else printf("输入错误!请重新输入\n");}while(c!='b'&&c!='B');}/************************************************************************/student * name_search(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/char s[15]; /*姓名*/char c;system("cls");printf("\n请输入要查询的学生姓名:"); /*提示输入姓名*/scanf("%s",&s); /*接收输入的姓名*/for(i=0;i<MAXNUM&&stuArray[i]!=NULL;i++) /*对学生信息数组中的每条学生信息进行循环*/{if(strncmp(stuArray[i]->name,s,15)==0) /*学生信息数组中是否存在与输入的学生姓名相同的记录*/{printf("\n存在要查询的学生记录!");getch(); /*找到了指定的学生记录*/break; /*跳出循环,不再查找*/}}if((i==MAXNUM) || (stuArray[i]==NULL)) /*是否找遍数组中的所有记录*/{printf("\n不存在要查询的学生记录!");getch(); /*没有找到指定的学生记录*/return NULL; /*返回菜单选择界面*/}/*输出要查询的学生信息开始*/printf("\n********------------**********这是要查询的记录吗?**********------------********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|------------|------|------|------|------|------|------|------|--------|------|\n");printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%6d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("\n********------------**********这是要查询的记录吗?**********------------********\n");/*输出要查询的学生信息结束*/do{printf("返回请输入b or B!\n");scanf("%c",&c);if(c=='b'||c=='B')return NULL;else printf("输入错误!请重新输入\n");}while(c!='b'&&c!='B');}/************************************************************************/ void gra_search(student * stuArray[MAXNUM]){int i[4] = {0, 0, 0, 0}; //分数<60int j[4] = {0, 0, 0, 0}; //分数60-69int k[4] = {0, 0, 0, 0}; //分数70-79int l[4] = {0, 0, 0, 0}; //分数80-89int m[4] = {0, 0, 0, 0}; //分数>90int c = 0; //课程选项system("cls");for (int t=0; stuArray[t+1]!=NULL && t<MAXNUM; t++){for (c = 0; c < 4; c++){if (stuArray[t]->score[c] < 60){i[c]++;}else if (stuArray[t]->score[c]>=60 && stuArray[t]->score[c]<70){j[c]++;}else if (stuArray[t]->score[c]>=70 && stuArray[t]->score[c]<80){k[c]++;}else if (stuArray[t]->score[c]>=80 && stuArray[t]->score[c]<90){l[c]++;}else{m[c]++;}}}printf("\n\n***********---------********-----平均成绩统计-----********---------***********\n");//班级待写printf(" | < 60 | 60 - 69 | 70 - 79 | 80 - 89 | > 90 |\n");printf("语文");printf("|%8d|%9d|%9d|%9d|%8d|\n",i[0], j[0], k[0], l[0], m[0]);printf("数学");printf("|%8d|%9d|%9d|%9d|%8d|\n",i[0], j[0], k[0], l[0], m[0]);printf("英语");printf("|%8d|%9d|%9d|%9d|%8d|\n",i[0], j[0], k[0], l[0], m[0]);printf("政治");printf("|%8d|%9d|%9d|%9d|%8d|\n",i[0], j[0], k[0], l[0], m[0]);printf("|------------------------------------------------------------------------------|\n");}/************************************************************************/void lar_search(student * stuArray[MAXNUM]){system("cls");int i = MAXNUM, j, last;student *temp;while (i > 1){last = 1;for (j = 1; j < i; j++){if (stuArray[j]->sum > stuArray[j+1]->sum){temp = stuArray[j];stuArray[j] = stuArray[j+1];stuArray[j+1] = temp;last = j;}i = last;}}printf("**************-----------**********学生成绩表**********------------*************\n");printf("\n");printf("********************************************************************* ***********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|------------|------|------|------|------|------|------|------|--------|------|\n");for(i=0;i<MAXNUM&&stuArray[i]!=NULL;i++) /*依次输出学生信息数组中每名学生的信息*/{printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%8d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("|------------------------------------------------------------------------------|\n");}}/************************************************************************/void total(student * stuArray[MAXNUM]){int i=0; /*学生记录行号*/int j=0; /*学生记录行号*/int k=0; /*班级科目数*/int l=0; /*学生人数*/int sum[MAXSUB];int sum_1; /*班级总分*/float average; /*班级平均分*/char banji_1[10]; /*班级*/ char banji_2[10]; /*班级*/ printf("\n\n**********-----------********---------统计---------********-----------**********\n");printf("|----------|----|-------------总分---------|-----------平均分---------|\n");printf("| 班级|人数|语文|数学|英语|政治| 总计|语文|数学|英语|政治| 总计|\n");printf("|----------|----|----|----|----|----|------|----|----|----|----|------|\n");while(stuArray[i]!=NULL) /*对学生信息数组中的每条学生记录进行循环*/{strcpy(banji_1,stuArray[i]->cl); /*把当前学生班级放到班级变量中*/sum_1=stuArray[i]->sum;average=stuArray[i]->average;for(k=0;k<4;k++){sum[k]=stuArray[j]->score[k];}l=1; /*记录班级学生数*/j=i+1; /*从学生信息数组中的第i+1条记录循环到最后一条记录*/while(stuArray[j+1]!=NULL){strcpy(banji_2,stuArray[j]->cl); /*把当前学生班级放到班级变量中*/if(strcmp(banji_1,banji_2)==0) /*比较两个学生是否同一班级*/{sum_1+=stuArray[j]->sum; /*将当前学生成绩加入本班总成绩*/average+=stuArray[j]->average; /*将当前学生平均成绩加入本班平均成绩*/for(k=0;k<4;k++){sum[k]+=stuArray[j]->score[k];}l++; /*统计班级学生数*/j++;}else /*不是同一班级*/{break; /*跳出循环,结束当前统计*/}}//printf("nihao\n");printf("|%-10s|%4d|%4d|%4d|%4d|%4d|%6d|%4d|%4d|%4d|%4d|%6.1f|\n",banji_1,l,su m[0],sum[1],sum[2],sum[3],sum_1,sum[0]/l,sum[1]/l,sum[2]/l,sum[3]/l,average/l);printf("|------------------------------------------------------------------------------|\n");if(stuArray[i]==NULL) /*如果同一班级下条记录没有,跳出循环*/{break;}else{i=j; /*否则将当前记录作为新的班级的第一条记录开始新的比较*/}}printf("\n\n**********-----------********---------统计---------********-----------**********\n");}/************************************************************************/void output(student * stuArray[MAXNUM]){int i;printf("**************-----------**********学生成绩表**********------------*************\n");printf("\n");printf("********************************************************************* ***********\n");printf("| 学号| 班级| 姓名| 性别| 语文| 数学| 英语| 政治| 总分|平均分|\n");printf("|------------|------|------|------|------|------|------|------|--------|------|\n");for(i=0;i<MAXNUM&&stuArray[i]!=NULL;i++) /*依次输出学生信息数组中每名学生的信息*/{printf("|%-12s|%-6s|%-6s|%-6s|%6d|%6d|%6d|%6d|%8d|%6.2f|\n",stuArray[i]->nu,stuAr ray[i]->cl,stuArray[i]->name,stuArray[i]->sex,stuArray[i]->score[0],stuArray[i]->score[1],stuArray[i]->score[2],stuArray[i]->score[3],stuArray[i]->sum,stuArray[i]->average);printf("|------------------------------------------------------------------------------|\n");}return;}/************************************************************************/void save(student * stuArray[MAXNUM]){int i; /*记录的行号*/FILE * fp, * fp1, * fp2;/*创建文件指针*/if((fp=fopen("data\\stu_list.dat","wb"))==NULL) /*stu_list打开文件,不存在则退出*/{printf("保存文件出错!\n");getch();return;}if((fp1=fopen("data\\101-1.dat","wb"))==NULL) /*101-1打开文件,不存在则退出*/{printf("保存文件出错!\n");getch();return;}if((fp2=fopen("data\\101-2.dat","wb"))==NULL) /*101-2打开文件,不存在则退出*/{printf("保存文件出错!\n");getch();return;}for (i=0;stuArray[i]!=NULL;i++){if (!strcmp(stuArray[i]->cl,"101-1")){if(fwrite(stuArray[i],sizeof(student),1,fp1)!=1) /*将学生记录的信息写入fp1指向的文件中*/printf("保存文件出错!\n");}else if (!strcmp(stuArray[i]->cl,"101-2")){if(fwrite(stuArray[i],sizeof(student),1,fp2)!=1) /*将学生记录的信息写入fp2指向的文件中*/printf("保存文件出错!\n");}}for(i=0;i<MAXNUM&&stuArray[i]!=NULL;i++){if(fwrite(stuArray[i],sizeof(student),1,fp)!=1) /*将学生记录的信息写入fp指向的文件中*/printf("保存文件出错!\n");}printf("%d",i);fclose(fp); /*关闭文件*/return;}/************************************************************************/void load(student * stuArray[MAXNUM]){FILE* fp; /*创建文件指针*/int i;if((fp=fopen("data\\stu_list.dat","rb"))==NULL) /*stu_list打开文件,不存在则退出*/{printf("导入文件出错!\n");getch();return;}for(i=0;!(feof(fp));i++){if (i>0){stuArray[i]=(student * )malloc(sizeof(student));}fread(stuArray[i],sizeof(student),1,fp); /*将fp指向的文件中的数据读入并保存在stuArray数组中*/}i--;stuArray[i]=(student * )malloc(sizeof(student));printf("%d",i);for (;i < MAXNUM;i++){stuArray[i] = NULL;}printf("导入文件成功!\n");fclose(fp);getch();return;}/************************************************************************/。