学生信息管理系统C语言编程
c语言学生管理系统代码
C语言学生管理系统代码
简介
学生管理系统是一个用于管理学生信息的简单程序,它可以实现添加学生信息、显示学生信息、修改学生信息和删除学生信息等功能。
通过这个系统,学校或机构可以更方便地管理和维护学生的相关数据。
功能
1.添加学生信息:通过输入学生的姓名、学号、年龄和性别等信息,将
学生信息存储在系统中。
每个学生信息包括学号、姓名、年龄和性别等关键信息。
2.显示学生信息:可以显示系统中所有学生的信息,包括学号、姓名、
年龄和性别。
3.修改学生信息:通过输入学生的学号,可以修改该学生的姓名、年龄
和性别等信息。
4.删除学生信息:通过输入学生的学号,可以删除该学生的信息。
实现
下面是一个简单的C语言学生管理系统代码示例:
```c #include <stdio.h> #include <string.h>
#define MAX_STUDENTS 100
// 定义学生结构体 struct Student { int id; char name[100]; int age; char
gender[10]; };
// 定义全局变量,用于存储学生信息和统计学生数量 struct Student
students[MAX_STUDENTS]; int num_students = 0;
// 添加学生 void addStudent() { if (num_students >= MAX_STUDENTS) { printf(。
学生管理系统c语言源代码
int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);
c语言程序设计学生信息管理系统
c语言程序设计学生信息管理系统学生信息管理是学校管理系统中非常重要的一部分,因此我们需要一个高效的系统进行管理。
在此背景下,C语言程序设计可以成为一个非常有用的工具。
首先,我们需要定义学生信息的数据结构。
通常情况下,学生信息包括姓名,性别,年龄,出生日期,籍贯,班级等等。
我们可以使用结构体来定义这个数据类型,代码如下:```typedef struct{char name[20];char sex[10];int age;char birth[20];char place[20];char clazz[20];}STUDENT;```其中,我们使用了char数组来存储字符串类型的数据。
在使用数组之前,我们需要考虑数据大小,以免溢出。
在这里,我们将数组的大小设置为了20。
接下来,我们需要实现学生信息的输入和输出功能。
我们可以使用scanf函数来输入信息,使用printf函数来输出信息。
代码如下:```void input_stu(STUDENT *stu){printf("Input Student's Name:");scanf("%s",stu->name);printf("Input Student's Gender:");scanf("%s",stu->sex);printf("Input Student's Age:");scanf("%d",&stu->age);printf("Input Student's Birth:");scanf("%s",stu->birth);printf("Input Student's Place:");scanf("%s",stu->place);printf("Input Student's Class:");scanf("%s",stu->clazz);}void output_stu(STUDENT *stu){printf("Name:%s\n",stu->name);printf("Gender:%s\n",stu->sex);printf("Age:%d\n",stu->age);printf("Birth:%s\n",stu->birth);printf("Place:%s\n",stu->place);printf("Class:%s\n",stu->clazz);}```注意,在使用scanf函数输入字符串类型的数据时,应该使用%s 格式控制符。
C语言实现学生信息管理系统
CMD_START /* 在屏幕上打印一行分隔符,告诉用户这是一个子功能的开始 */
switch( cmd ) /* 用多项分支 根据 用户的选择 调用 相应的函数 */
{
case 1:
Print(); break; /* 用户选择 1 号菜单,程序执行 查看的数据文件的函数 */
printf(Menu_SeeData);
printf(Menu_Add);
printf(Menu_Delete);
printf(Menu_Statistics);
printf(Menu_Find_ID);
printf(Menu_Find_Name);
printf(Menu_Quit);
/* 用户所输入的 序号不在所处理的范围内 */
}
CMD_END /* 打印一行分隔符,告诉用户 他所选择的菜单的功能已经执行完毕 */
if (quit != 1) /* 检查用户是否 要求 退出 */
{
printf(" Press any key to Return Main Menu ....\n");
case 5:
Find(5); break; /* Find_ID ,5 号菜单执行 按 ID(学号)查找的功能 */
case 6:
Find(6); break; /* Find_Name,6 号菜单执行 按 Name(姓名)查找的功能 */
case 7:
}
printf("\n The current data file have\t%d\trecord .\n" , i );
fclose(fp); /* 关闭文件 */
学生管理系统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语言编写的一个学生信息管理系统
用C语言实现线性表的基本操作,能创建一个基于学生信息管理的链表,至少包含数据输入、数据输出、数据处理等操作。
在主函数里能实现以下功能。
运行后出现一个选择提示。
可选择的功能有1)创建新的学生信息链表2)增加一个新的学生信息3)按学号删除某个学生信息4)按学号查找某个学生信息5)可以按照学生成绩对链表排序6)退出系统#include "stdio.h"#include "stdlib.h"#include "string.h"#include "conio.h"jiemian();struct student{char name[50];char sex[5];int age;char num[50];float score1;float score2;float score3;float sum;float ave;}stu[50],del;void gn1(){int i=0;char num1;for(i=0;i<50;i++){printf("请输入要添加的学生资料:\n");printf("学号:");scanf("%s",stu[i].num);printf("姓名:");scanf("%s",stu[i].name);printf("性别:");scanf("%s",&stu[i].sex);printf("年龄:");scanf("%d",&stu[i].age);printf("请输入学生的三门成绩:\n");printf("语文:");scanf("%f",&stu[i].score1);printf("数学:");scanf("%f",&stu[i].score2);printf("英语:");scanf("%f",&stu[i].score3);printf("是否继续添加:y/n\n");scanf("%c",&num1);scanf("%c",&num1);if(num1=='N' || num1=='n'){system("cls");jiemian();}}}void gn2(){int i;char num[50];printf("请输入要查找的学生学号:\n");scanf("%s",num);for(i=0;i<50;i++)if(strcmp(stu[i].num,num)==0){stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum/3;printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i].num,stu[i].name,stu[i].sex,stu[i] .age,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].sum,stu[i].ave);break;}if(i==50)printf("查找不到!请重新输入!\n");getch();system("cls");jiemian();}void gn3(){char num1,i=0;printf("请输入要修改的学生学号:\n");scanf("%s",stu[i].num);printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i].num,stu[i].name,stu[i].sex,stu[i] .age,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].sum,stu[i].ave);printf("姓名:");scanf("%s",stu[i].name);printf("性别:");scanf("%s",stu[i].sex);printf("年龄:");scanf("%d",&stu[i].age);printf("请输入学生的三门成绩:\n");printf("语文:");scanf("%f",&stu[i].score1);printf("数学:");scanf("%f",&stu[i].score2);printf("英语:");scanf("%f",&stu[i].score3);printf("是否继续修改:y/n?\n");scanf("%c",&num1);scanf("%c",&num1);if(num1=='N' || num1=='n')system("cls");jiemian();}void gn4(){int i;char num[50];printf("请输入要删除的学生学号:\n");scanf("%s",num);for(i=0;i<50;i++)if(strcmp(num,stu[i].num)==0){printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i].num,stu[i].name,stu[i].sex,stu[i] .age,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].sum,stu[i].ave);stu[i]=del;printf("信息已删除,按任意键返回..\n");break;}if(i==50)printf("您输入的信息不存在!\n");getch();system("cls");jiemian();}void gn5(){int i=0;stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum/3;printf("学号\t姓名\t性别\t年龄\t语文\t数学\t英语\t总成绩\t 平均成绩\n"); for(i=0;i<50;i++){if(stu[i].age==0)break;printf("%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n",stu[i].num,stu[i].name,stu[i].sex,stu[i] .age,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].sum,stu[i].ave);}printf("按任意键返回...");getch();system("cls");jiemian();}void gn6(){FILE *fp;int i;char filename[50];printf("\n");printf("\n");printf("请输入要保存的文件名:");scanf("%s",filename);if((fp=fopen(filename,"wb"))==NULL)printf("文件名为空,不能保存!\n");for(i=0;i<50;i++){if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)printf("文件保存失败!\n");}fclose(fp);printf("文件已保存!\n");printf("按任意键返回...\n");getch();system("cls");jiemian();}void gn7(){FILE *fp;int i=0; //打开文件流char filename[50];printf("请输入文件名:");scanf("%s",filename); //输入要载入的文件名if((fp=fopen(filename,"rb"))==0) //如果当前目录下不存在相对应的文件,输出文件不存在,退出系统。
用c语言编写的一个学生信息管理系统
路漫漫其修远兮,吾将.上F而求索・百度文库用C语言实现线性表的基本操作,能创建一个基于学生信息管理的链表,至少包含数据输入、数据输出、数据处理等操作。
在主函数里能实现以下功能。
运行后出现一个选择提示。
可选择的功能有1)创建新的学生信息链表2)增加一个新的学生信息3)按学号删除某个学生信息4)按学号查找某个学生信息5)可以按照学生成绩对■链表排序6)退出系统#include "stdio.h"#include "stdlib.h"#include "string.h n#include ,,conio.h Hjiemian();struct student(char name[50];char sex[5];int age;char num[50];float scorel;float score2;float score3;float sum;float ave;}stu[50],del;void gnl()(int i=0;char numl;for(i=0;i<50;i++)(printf「请输入要添加的学生资料:\n“);printf(“学号巧;scanf("%s",stu[i].num);printf("姓名巧;scanf("%s",stu[i].name);printf(“性别巧;scanf("%s",&stu[i].sex);printf(“年龄巧;scanf("%d",&stu[i].age);11目上下而求索•百度文库printf(”请输入学生的三门成绩:'俏;printf("语文门;scanf(,,%f,,,&stu[i].scorel);printf(“数学门;scanf(,,%f,,,&stu[i].score2);printf("英语巧;scanf(,,%f,,,&stu[i].score3);printf("是否继续添加:y/n\n“); scanf(,,%c,,,&numl);scanf(,,%c,,,&numl);if(numl==,N, 11 numl=="n,){system(,,cls"); jiemian();)))void gn2()(int i;char num[50];printf「请输入要查找的学生学号:\n“);scanf(,,%s,,/num);for(i=0;i<50;i++)if(strcmp(stu[i].num,num)==O) (stu[i].sum=stu[i].scorel+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum^;printf(',%s\t%s\t%s\t%d\t%,2f\t%.2f\t%.2f\t%.2f\t%.2f:\n'l/stu[i].num/stu[i].name/stu[i].sex/stu[i] .age,s tu[i].scorel/stu[i].score2/stu[i].score3/stu[i].sum/stu[i].ave);break;)if(i==50)printf("查找不到!请重新输入!\n");22路漫漫其修远兮,吾将上F而求索・百度文库getch(); systemf'cls"); jiemian();)void gn3()(char numlJ=0;printf("请输入要修改的学生学号:\n“);scanf(,,%s,,/stu[i].num);printf(,l%s\t%s\t%s\t%d\t%,2f\t%.2f\t%.2f\t%.2f\t%.2f:\n'l/stu[i].num/stu[i].name/stu[i].sex/stu[i] .age,s tu[i].scorel/stu[i].score2/stu[i].score3/stu[i].sum/stu[i].ave);printf("姓名门;scanf(,,%s,,/stu[i].name);printf(“性别门;scanf(,,%s,,/stu[i].sex);printf("年龄门;scanf(,,%d,,,&stu[i].age);printf(“请输入学生的三门成绩:\n“);printf("语文门;scanf(,,%f,,,&stu[i].scorel);printf(“数学门;scanf(,,%f,,,&stu[i].score2);printf("英语门;scanf(,,%f,,,&stu[i].score3);printf("是否继续修改:y/n?\n“);scanf(,,%c"/&numl);scanf(,,%c,\&numl);if(numl==,N, 11 numl==,n,)systemf'cls"); jiemian();)void gn4()(int i;char num[50];printf("请输入要删除的学生学号:\n“);scanf(,,%s,,,num);for(i=0;i<50;i++) 33if(strcmp(num,stu[i].num)==O)(printf(,,%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n,,/stu[i].num/stu[i].name/stu[i].sex/stu[i] .age,stu[i].scorel/stu[i].score2/stu[i].score3/stu[i].sum/stu[i].ave);stu[i]=del;printf("信息已删除,按任意键返回..\n“); break;)if(i==50)printf ("您输入的信息不存在!\n”);getch();system("cls"); jiemian();)void gn5()(int i=0;stu[i].sum=stu[i].scorel+stu[i].score2+stu[i].score3;stu[i].ave=stu[i].sum/3;printf("学号\t姓名\t性别\t年龄\t语文\t数学\t英语\t总成绩\t平均成绩\n");for(i=0;i<50;i++)(if(stu[i].age==O)break;printf(,,%s\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f:\n,,/stu[i].num/stu[i].name/stu[i].sex/stu[i] .age,stu[i].scorel/stu[i].score2/stu[i].score3/stu[i].sum/stu[i].ave);)printf("按任意键返回.getch();system(,,cls n);jiemian();)void gn6()(FILE *fp;int i;char filename[50];printf(,,\n N); 44路漫漫其修远兮,吾将上F而求索・百度文库printf(,,\n M);printf(“请输入要保存的文件名:");scanf(”%s”,filename);if((fp=fopen(filename/,wb,,))==NULL)printf("文件名为空,不能保存!\n");for(i=0;i<50;i++)(if(fwrite(&stu[i],sizeof(struct student),l,fp)!=l) printf("文件保存失败!\n”);)fclose(fp);printf (“文件己保存!\n“);printf。
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语言编写学生管理系统的代码
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#include<conio.h>struct student{char number[21];char name[21];int age;char sex[3];char birthday[8];}studentArray[100];typedef struct student student;student studentArray[100];char putout[5][12]={"学号","姓名","年龄","性别","出生年月"}; //为格式化输出做准备int count=0;//函数声明部分void explain();void readfile();void searchStudent();void modifyStudent();void addStudent();void delStudent();void printAllstudent();void save();void quit();void initial();void initial(){FILE *fp;char choice='y';int i=0;fp=fopen("e:\\students.txt","r");if(!fp){printf("创建文件失败,即将返回\n");return ;}for(;fread(&studentArray[i],sizeof(struct student),1,fp)!=0;i++);count=i;}//0、说明模块void explain(){printf("\n 很高兴能为您服务\n");printf("\n1.进入本系统,请先刷新学生信息,再查训\n");printf("\n2.您可以根据自己需要的信息键入菜单上的编号\n");printf("\n3.修改学生信息后记得退出前保存信息,以免信息流失\n");printf("\n4.在各个子菜单里按提示操作\n");printf("\n5.谢谢您的使用及支持\n");}//1、刷新模块void readfile(){char *p="students.txt";FILE *fp;int i=0;if((fp=fopen("students.txt","r"))==NULL){printf("打开文件%s出错!请按按任意键返回",p);system("pause");{i++;i=i;}fclose(fp);printf("刷新完毕。
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语言版源代码
学生信息管理系统c语言版源代码#include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 1000typedef struct student {int number;char name[20];int grade;int gaoshu;int yingyu;int jisuanji;int sum;}STUDENT;STUDENT student[N]; int shuliang=0;void menu();void fhzjm(){char biaozhi[20];printf("\n");printf("还需要操作么,如果需要操作请输入:yes,否则请输入:no\n");scanf("%s",biaozhi);if(strcmp(biaozhi,"yes")==0){menu();}else if(strcmp(biaozhi,"no")==0)exit(0);else{printf("请输入正确的字符,谢谢~\n"); fhzjm();}}void DengJi(){int rs;int i,k=1;system("CLS");printf("请输入需要输入几个学生信息:"); scanf("%d",&rs);for(i=shuliang;i<shuliang+rs;i++,k++) {printf("请输入第%d个学生的学号:",k); scanf("%d",&student[i].number);printf("请输入学生的姓名:");scanf("%s",student[i].name);printf("请输入学生3门课的成绩:"); printf("请输入第1门课的成绩:");scanf("%d",&student[i].gaoshu);printf("请输入第2门课的成绩:");scanf("%d",&student[i].yingyu);printf("请输入第3门课的成绩:");scanf("%d",&student[i].jisuanji);}shuliang=shuliang+rs;fhzjm();}void ShanChu(){char shanchuinfo[10];system("CLS");printf("删除全部学生信息请输入\"all\",删除指定学号的学生信息请输入\"one\"\n");scanf("%s",shanchuinfo);if(strcmp(shanchuinfo,"all")==0){int j;printf("你删除的学生信息如下:\n");printf("-----------学号-------------姓名-------------高数--------------英语--------------计算机\t\n");for(j=0;j<shuliang;j++)printf("----%d-------%s-------%d-------%d-------%d\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].jisuanji);shuliang=0;printf("删除成功\n\n");}else if(strcmp(shanchuinfo,"one")==0){struct student *p=NULL;int choice;int i,j,k=0;printf("请输入你要删除的人的学号:");scanf("%d",&choice);for(i=0;i<shuliang;i++){if(choice==student[i].number){k=1;j=i;break;}}if(k){if(shuliang==1){p=&student[0];free(p);shuliang=0;}else{for(i=j;i<shuliang;i++) {student[i]=student[i+1];}shuliang=shuliang-1;}printf("删除成功\n\n");}else{printf("输入数据错误~\n"); }}fhzjm();}void LiuLan(){int i;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");}else{for(i=0;i<shuliang;i++){printf("第%d个学生的学号为:%d\n",i+1,student[i].number);printf("第%d个学生的姓名为:%s\n",i+1,student[i].name);printf("第%d个学生的第一门课的成绩为:%d\n",i+1,student[i].gaoshu);printf("第%d个学生的第二门课的成绩为:%d\n",i+1,student[i].yingyu);printf("第%d个学生的第三门课的成绩为:%d\n",i+1,student[i].jisuanji);student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("第%d个学生的总成绩为:%d\n",i+1,student[i].sum);}}fhzjm();}void ChaZhao(){int xx;char choice,yy[20];int i,j,k=0;system("CLS");if(shuliang==0){printf("系统里面没有任何学生的信息~\n");fhzjm();}printf("三种查找方式:学号,姓名,成绩\n");printf("如果按学号查找请输1,如果按姓名查找请输2,如果按成绩查找请输3\n");printf("请输入您查找的方式:");scanf("%s",&choice);if(choice=='1'){printf("请输入需要查找学生的学号:");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].number){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='2'){printf("请输入需要查找学生的姓名:\n");scanf("%s",yy);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数成绩----英语成绩----计算机成绩----\t\n");for(i=0;i<shuliang;i++){if(strcmp(yy,student[i].name)==0){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[j].jis uanji);}}if(k==0)printf("输入信息有误:\n");}else if(choice=='3'){printf("请输入需要查找学生的成绩:\n");scanf("%d",&xx);printf("您所查找的学生的信息为:\n");printf("----学号----姓名----高数----英语----计算机----\t\n");for(i=0;i<shuliang;i++){if(xx==student[i].grade){j=i;k=1;printf("----%d-------%s-------%d-------%d-------%d----\t\n",student[j].number,student[j].name,student[j].gaoshu,student[j].yingyu,student[i].jis uanji);}}if(k==0)printf("输入信息有误:\n");}fhzjm();}void PaiXu(){struct student *p1[N],**p2,*temp;int i,j;system("CLS");p2=p1;for( i=0;i<shuliang;i++){p1[i]=student+i;}for( i=0;i<shuliang;i++){for( j=i+1;j<shuliang;j++){if((*(p2+i))->sum<(*(p2+j))->sum){temp=*(p2+i);*(p2+i)=*(p2+j);*(p2+j)=temp;} }}printf("按照总成绩排序之后的信息为:\n");printf("----学号----姓名----总成绩----\t\n");for( i=0;i<shuliang;i++){student[i].sum=student[i].gaoshu+student[i].yingyu+student[i].jisuan ji;printf("----%d-----%s----%d-----\n",(*(p2+i))->number,(*(p2+i))->name,(*(p2+i))->sum);}fhzjm();}void CunChu(){int i;FILE *rs;if((rs=fopen("student.txt","w"))==NULL){printf("not open");exit(0);}for(i=0;i<shuliang;i++){fwrite(&student[i], sizeof(student[i]), 1, rs); }if(ferror(rs)){fclose(rs);perror("写文件失败~\n");return;}printf("存储文件成功~\n");fclose(rs);fhzjm();}void DaoChu(){struct student t;int i=0;FILE* fp = fopen("student.txt", "r");shuliang=0;if(NULL==fp){perror("读取文件打开失败~\n");return;}memset(student,0x0,sizeof(student));while(1){fread(&t,sizeof(t),1,fp);if(ferror(fp)){fclose(fp);perror("读文件过程失败~\n");return;}if(feof(fp)){break;}student[i]=t;i++;}fclose(fp);shuliang=i; printf("导出文件成功~\n"); fhzjm();}void menu(){int n=0;system("CLS");printf(" 学生信息管理系统\n");printf(" 作者:陈椿\n");printf("-------------------MENU-----------------\n"); printf(" 1.登记学生信息\n");printf(" 2.删除学生信息\n");printf(" 3.浏览所有已经登记的学生\n");printf(" 4.查找\n");printf(" 4.1按学号查找\n");printf(" 4.2按姓名查找\n");printf(" 4.3按成绩查找\n");printf(" 5.根据总成绩排序\n");printf(" 6.存储到文件\n");printf(" 7.从文件导出\n");printf(" 8.退出系统\n");a: printf(" 请选择:");scanf("%d",&n);switch (n){case 1:DengJi();break;case 2:ShanChu();break;case 3:LiuLan();break;case 4:ChaZhao();break;case 5:PaiXu();break;case 6:CunChu();break;case 7:DaoChu();break;case 8:exit(0);break;default:{printf("请输入1-8之间的数字,谢谢~\n"); goto a;}}}main() {menu();}。
学生管理系统c语言源代码
学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。
学生管理系统 C语言代码
#include"stdio.h"#include"stdlib.h"#include"string.h"struct stu_info1{char num[13];//学号char name[10];//姓名char sex[5];//性别char cls[20];//班级}stu1[6];struct stu_info2{char counum[6];//课程号char counam[20];//课程名称int credit;//学分}stu2[6];struct stu_info3{char num[13];//学号char counum[6];//课程号float results;//分数}stu3[12];struct stu_info4{char num[13];//学号char counum[6];//课程号float results;//分数}stu4[12];int n=11;void main(){void gengxin();void input1();void input2();void input3();void output();void xianshi();void chaxun();void printf1();void printf2();input1();input2();output();int i;loop: ;printf("*************欢迎使用分数查询系统*************\n");printf("** 请选择**\n");printf("** 1.录入2.删除无用信息(管理员功能) **\n");printf("** 3.显示4.查询(学生功能) **\n");printf("** 5.显示学生信息6.显示课程信息**\n");printf("** 7.退出**\n");printf("**********************************************\n");scanf("%d",&i);switch(i){case 1: input3();break;case 2:gengxin();break;case 3:xianshi();goto loop;case 4: chaxun();goto loop;case 5: printf1();goto loop;case 6: printf2();goto loop;case 7:break;default:printf("error");break;}}void input1()//录入结构体stu1[]{int i;FILE *fp;if((fp=fopen("A.txt","r"))==NULL){printf("can not open file\n");exit(0);}/* printf(" 学号姓名性别班级\n");*/for(i=0;i<=5;i++){fscanf(fp,"%s%s%s%s",&stu1[i].num,&stu1[i].name,&stu1[i].sex,&stu1[i].cls);/*printf("%-13s %-10s %-5s %-20s\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i] .cls);*/}fclose(fp);}void input2()//录入结构体stu2[]{int i;FILE *fp;if((fp=fopen("B.txt","r"))==NULL){printf("can not open file\n");exit(0);}for(i=0;i<=5;i++){fscanf(fp,"%s%s%d",&stu2[i].counum,&stu2[i].counam,&stu2[i].credit);}fclose(fp);}void input3()//录入成绩{FILE *fp;fp=fopen("C.txt","w");int a,i,j,k;float cetss;char number[13],cnum[6],mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){printf("请输入要录入学生成绩的个数\n");scanf("%d",&a);for(i=1;i<=a;i++){printf("请输入要录入的第%d同学的学号:",i);scanf("%s",number);printf("请输入要录入的第%d同学的课程号:",i);scanf("%s",cnum);for(j=0;j<=5;j++)//学号{if((strcmp(number,stu1[j].num)==0))break;}if(j<=5){for(k=0;k<=5;k++)//课程号{if(strcmp(cnum,stu2[k].counum)==0){printf("请输入要录入同学的成绩:");scanf("%f",&cetss);fprintf(fp,"%s %s %f\n",number,cnum,cetss);break;}}}if(j>5||k>5){printf("Error,please input again");i=i-1;}printf("录入成功\n");}}else{printf("密码错误\n");}}void output()// 录入结构体stu3[]{int i;FILE *fp=fopen("C.txt","r");for(i=0;i<n;i++){fscanf(fp,"%s%s%f",&stu3[i].num,&stu3[i].counum,&stu3[i].results);/*printf("%s%s%f\n",stu3[i].num,stu3[i].counum,stu3[i].results);*/ }fclose(fp);}void xianshi()// 显示成绩{int i,j;for(i=0;i<n;i++){for(j=0;j<6;j++){if((strcmp(stu3[i].num,stu1[j].num))==0)printf("%s\t",stu1[j].name);}for(j=0;j<6;j++){if(strcmp(stu3[i].counum,stu2[j].counum)==0)printf("%s\t",stu2[j].counam);}printf("%3.1f\n",stu3[i].results);}}void chaxun()//查询功能{char number[13],c;int i,j,k,a,b,d;while((c=getchar())!='Q'){a=0,b=0;//a记录学分b记录学科printf("请输入要查询同学的学号\n");scanf("%s",number);for(i=0;i<n;i++){if(strcmp(number,stu3[i].num)==0){printf("学号:%s\t",stu3[i].num);for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){printf("姓名:%s\n",stu1[j].name);}}break;}}d=i;for(i=0;i<n;i++)if(strcmp(number,stu3[i].num)==0){b=b+1;for(j=0;j<6;j++){if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<6;k++){if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;}break;}}if(stu3[i].results>=60){a=a+stu2[k].credit;printf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,stu2[k].credit);}elseprintf("课程号:%s\t课程名称:%s\t成绩:%3.1f\t实得学分:%d\n",stu3[i].counum,stu2[k].counam,stu3[i].results,0);}if(d<n){printf("共修%d科\t\t实得总学分:%d\n",b,a);}else{printf("学号输入错误\n");}getchar();printf("退出请按Q+回车,继续查询请按回车键");}}void gengxin()//更新信息,删除C.txt中无用信息{FILE *fp;int i,j,k;char mima[10];printf("请输入管理员密码\n");scanf("%s",mima);if(strcmp(mima,"abc111")==0){fp=fopen("C.txt","w");for(i=0;i<n;i++){for(j=0;j<6;j++)if(strcmp(stu3[i].num,stu1[j].num)==0){for(k=0;k<=5;k++)if(strcmp(stu3[i].counum,stu2[k].counum)==0)break;if(k<=5){fprintf(fp,"%s %s %f\n",stu3[i].num,stu3[i].counum,stu3[i].results);}}}printf("更新C.txt成功\n");fclose(fp);}else{printf("密码错误\n");}}void printf1()//显示学生信息{int i;printf(" 学号姓名性别班级\n");for(i=0;i<=5;i++){printf("%-13s%-10s%-5s %-20s\n\n",stu1[i].num,stu1[i].name,stu1[i].sex,stu1[i].cls);}}void printf2()//显示课程信息{int i;printf(" 课程编号课程名称学分\n");for(i=0;i<=5;i++){printf("%-6s%-20s %-4d\n\n",stu2[i].counum,stu2[i].counam,stu2[i].credit);}}。
用C语言编写学生信息管理系统
用C语言编写学生信息管理系统Design Purpose:Design Content:1. Problem n:Design a student n management system that includes student n such as student ID, name, age, gender, date of birth, address, phone number, and email.2. nal Requirements:1. The system works in menu mode.2. Student n entry n (student n is saved in a file) - input.3. Student n browsing n - output.4. Student n query n - algorithm according to student ID query and name query.Detailed Design:1. Menu: void menu() {}2. Establish n: void readfile() {}3. Search: void seek() {}4. Modify n: void modify() {}5. Insert n: void insert() {}6. Delete n:void del(){}7. Browse n:void display(){}8. Save:void save(){Debugging and Testing:1. System nal menu.2. Select the menu "", enter the system help and ns n.3. Select menu "4" to add student n. (1) Input the number of people to be added. (2) Enter the student ID, name, age, gender, date of birth, address, phone number, and email in order. After input, the menu pops up.#include#include#include#define BUFLEN 100 #define LEN 15struct record{char code[LEN+1]; char name[LEN+1]; int age;char sex[3];char time[LEN+1];char add[30];char tel[LEN+1];char mail[30];void readfile();void seek();void modify();void modify() {int i, item, num;char sex1[3], s1[LEN+1], s2[LEN+1];printf("请输入要修改的学生的学号:\n"); scanf("%s", s1);for (i = 0; i < n; i++) {if (strcmp(stu[i].code, s1) == 0) {num = i;}}printf("------------------\n");printf("1.修改姓名\n");printf("2.修改年龄\n");printf("3.修改性别\n");printf("4.修改出生年月\n");printf("5.修改地址\n");printf("6.修改电话号码\n");printf("7.修改E-mail地址\n");printf("8.退出本菜单\n");printf("------------------\n");while (1) {printf("请选择子菜单编号:");scanf("%d", &item);switch (item) {case 1:printf("请输入新的姓名:\n"); scanf("%s", s2);strcpy(stu[num].name, s2);break;case 2:printf("请输入新的年龄:\n");scanf("%d", &stu[num].age);break;case 3:printf("请输入新的性别:\n");scanf("%s", sex1);strcpy(stu[num].sex, sex1);break;case 4:printf("请输入新的出生年月:\n"); scanf("%s", s2);strcpy(stu[num].time, s2);break;case 5:printf("请输入新的地址:\n");scanf("%s", s2);strcpy(stu[num].add, s2);break;case 6:printf("请输入新的电话号码:\n");scanf("%s", s2);strcpy(stu[num].phone, s2);break;case 7:printf("请输入新的E-mail地址:\n");scanf("%s", s2);strcpy(stu[num].email, s2);break;case 8:return;default:printf("输入有误,请重新选择子菜单编号\n"); break;}}void input(){int i;char s[10];printf("请输入学生人数:\n"); scanf("%d",&n);for(i=0;i<n;i++){printf("请输入学号:\n");scanf("%s",stu[i].code);printf("请输入姓名:\n");scanf("%s",stu[i].name);printf("请输入性别:\n");scanf("%s",stu[i].sex);printf("请输入年龄:\n");scanf("%d",&stu[i].age);printf("请输入出生日期:\n"); scanf("%s",stu[i].time);printf("请输入家庭住址:\n"); scanf("%s",stu[i].add);printf("请输入电话号码:\n");scanf("%s",stu[i].tel);printf("请输入E-mail地址:\n");scanf("%s",stu[i].mail);}void modify(){int num,choice;char s2[10];printf("请输入要修改信息的学生的学号:\n");scanf("%s",s2);for(num=0;num<n;num++){if(strcmp(stu[num].code,s2)==0){printf("请选择要修改的信息:\n");printf("1.学号 2.姓名 3.性别 4.年龄 5.出生日期\n");printf("6.家庭住址 7.电话号码 8.E-mail地址 9.退出\n");scanf("%d",&choice);switch(choice){case 1:printf("请输入新的学号:\n"); scanf("%s",s2);strcpy(stu[num].code,s2);break;case 2:printf("请输入新的姓名:\n"); scanf("%s",s2);strcpy(stu[num].name,s2);break;case 3:printf("请输入新的性别:\n"); scanf("%s",s2);strcpy(stu[num].sex,s2);break;case 4:printf("请输入新的年龄:\n");scanf("%d",&stu[num].age);break;case 5:printf("请输入新的出生日期:\n"); scanf("%s",s2);strcpy(stu[num].time,s2);break;case 6:printf("请输入新的家庭住址:\n"); scanf("%s",s2);strcpy(stu[num].add,s2);break;case 7:printf("请输入新的电话号码:\n"); scanf("%s",s2);strcpy(stu[num].tel,s2);break;case 8:printf("请输入新的E-mail地址:\n"); scanf("%s",s2);strcpy(stu[num].mail,s2);break;case 9:return;default:printf("请在1-8之间选择\n"); }}}void sort(){int i,j,*p,*q,s;char temp[10];for(i=0;i<n-1;i++){for(j=n-1;j>i;j--){if(strcmp(stu[j-1].code,stu[j].code)>0){strcpy(temp,stu[j-1].code);strcpy(stu[j-1].code,stu[j].code); strcpy(stu[j].code,temp);strcpy(temp,stu[j-1].name);strcpy(stu[j-1].name,stu[j].name); strcpy(stu[j].name,temp);strcpy(temp,stu[j-1].sex);strcpy(stu[j-1].sex,stu[j].sex);strcpy(stu[j].sex,temp);strcpy(temp,stu[j-1].time);strcpy(stu[j-1].time,stu[j].time); strcpy(stu[j].time,temp);strcpy(temp,stu[j-1].add);strcpy(stu[j-1].add,stu[j].add);strcpy(stu[j].add,temp);strcpy(temp,stu[j-1].tel);strcpy(stu[j-1].tel,stu[j].tel);strcpy(stu[j].tel,temp);strcpy(temp,stu[j-1].mail);strcpy(stu[j-1].mail,stu[j].mail);strcpy(stu[j].mail,temp);p=&stu[j-1].age;q=&stu[j].age;s=*q;*q=*p;*p=s;}}}}void insert() {int i = n, j, flag;printf("请输入待增加的学生数:\n");scanf("%d", &m);do {flag = 1;while (flag) {flag = 0;printf("请输入第%d个学生的学号:\n", i + 1);scanf("%s", stu[i].code);for (j = 0; j < i; j++) {if (strcmp(stu[i].code, stu[j].code) == 0) {printf("已有该学号,请检查后重新录入!\n");flag = 1;break;}}}printf("请输入第%d个学生的姓名:\n", i + 1);scanf("%s", stu[i].name);printf("请输入第%d个学生的年龄:\n", i + 1);scanf("%d", &stu[i].age);printf("请输入第%d个学生的性别:\n", i + 1);scanf("%s", stu[i].sex);printf("请输入第%d个学生的出生年月:(格式:年.月)\n", i + 1);scanf("%s", stu[i].time);printf("请输入第%d个学生的地址:\n", i + 1);scanf("%s", stu[i].add);printf("请输入第%d个学生的电话:\n", i + 1); scanf("%s", stu[i].tel);printf("请输入第%d个学生的E-mail:\n", i + 1); scanf("%s", stu[i].mail);if (flag == 0) {i++;}} while (i < n + m);n += m;printf("录入完毕!\n\n");sort();void del() {int i, j, flag = 0;char s1[LEN + 1];printf("请输入要删除学生的学号:\n");scanf("%s", s1);for (i = 0; i < n; i++) {if (strcmp(stu[i].code, s1) == 0) {flag = 1;for (j = i; j < n - 1; j++) {stu[j] = stu[j + 1];}n--;printf("删除成功!\n\n"); break;}}if (flag == 0) {printf("未找到该学号!\n\n"); }。
学生信息管理系统C语言代码
#include <stdio.h>#include <string.h>#include <malloc.h>struct shengri{int year;int month;int day;};struct student{char name[40];char sno[20];char sid[20];struct shengri birth;int address[200];};struct student *stu=NULL;int current=0;int total=0;void insert(){if(stu==NULL)stu=(struct student *)malloc(total*sizeof(struct student));if(current>=total){printf("对不起,由于人数已满,不能添加新学生信息\n");return;}printf("请输入学生姓名: ");scanf("%s",stu[current].name);printf("请输入学生学号: ");scanf("%s",stu[current].sno);printf("请输入学生身份证号码: ");scanf("%s",stu[current].sid);printf("请输入学生出生日期格式(年-月-日): ");scanf(" %d-%d-%d",&stu[current].birth.year,&stu[current].birth.month,&stu[ current].birth.day);printf("请输入学生家庭地址: ");scanf("%s",stu[current].address);current++;return;}void query(){char name[40];char xuehao[40];int i,item,flag;printf("\n");printf("1.按学号查询\n");printf("2.按姓名查询\n");printf("3.退出本菜单\n");printf("\n");while(1){printf("\n");printf("请选择子菜单编号:");scanf("%d",&item);flag=0;switch(item){case 1:printf("请输入要查询的学生的学号:");scanf("%s",xuehao);for(i=0;i<current;i++)if(strcmp(stu[i].sno,xuehao)==0){flag=1;printf("学生信息如下\n");printf("姓名: %s\n",stu[i].name);printf("学号: %s\n",stu[i].sno);printf("身份证号: %s\n",stu[i].sid);printf("出生日期: %d-%d-%d\n",stu[i].birth.year,stu[i].birth.month,stu[i].birth.day); printf("家庭地址: %s\n",stu[i].address);return;}if(flag==0)printf("\n");printf(" 警告:学号为%s的学生不存在",xuehao);break;break;case 2:printf("请输入要查询的学生的姓名:");scanf("%s",name);for(i=0;i<current;i++)if(strcmp(stu[i].name,name)==0){flag=1;printf("学生信息如下\n");printf("姓名: %s\n",stu[i].name);printf("学号: %s\n",stu[i].sno);printf("身份证号: %s\n",stu[i].sid);printf("出生日期: %d-%d-%d\n",stu[i].birth.year,stu[i].birth.month,stu[i].birth.day); printf("家庭地址: %s\n",stu[i].address);return;}if(flag==0)printf("\n");printf(" 警告:姓名为%s学生不存在",name);break;case 3:return;default:printf("非法输入,请在1-3之间选择\n");}}}void update(){char name[40];int i;printf("请输入要修改的学生姓名: ");scanf("%s",name);for(i=0;i< current;i++){if(strcmp(stu[i].name,name)==0){printf("请输入修改后的学生姓名: ");scanf("%s",stu[i].name);printf("\n");printf("修改前的学生学号为: ");printf("%s",stu[i].sno);printf("\n");printf("请输入修改后的学生学号: ");scanf("%s",stu[i].sno);printf("\n");printf("修改前的学生身份证号为: ");printf("%s",stu[i].sid);printf("\n");printf("请输入修改后的学生身份证号: ");scanf("%s",stu[i].sid);printf("\n");printf("修改前的学生出生日期,格式(年-月-日):");printf("%d-%d-%d",stu[i].birth.year,stu[i].birth.month,stu[i].birth.day);printf("\n");printf("请输入修改后的学生出生日期,格式(年-月-日):");scanf("%d-%d-%d",&stu[i].birth.year,&stu[i].birth.month,&stu[i].birth.day);printf("\n");printf("修改前的家庭住址为: ");printf("%s",stu[i].address);printf("\n");printf("请输入修改后的家庭地址: ");scanf("%s",stu[i].address);return;}}printf(" 该学生不存在,请重新选择\n");return;}void deiete(){char name[40];int i,k;char a;printf("请输入要删除的学生姓名: ");scanf("%s",name);printf("\n");for(i=0;i< current;i++){if(strcmp(stu[i].name,name)==0){printf("要删除的学生姓名为:%s\n",stu[i].name);printf("\n");printf("你确定要删除吗?继续请按'y',放弃请按'n'\n");printf("\n");printf("请选择:");scanf("%s",&a);if (a=='y'||a=='Y'){for(k=i;k<current;k++)strcpy(stu[k].name,stu[k+1].name);break;}if(a=='n'||a=='N'){printf("放弃删除!");return;}printf("非法输入");return;}}if(i==current)printf("警告:姓名为%s的学生不存在\n\n",name);else{printf("该学生已成功删除!\n");current--;}return;}void list(){int i;printf("一共有%d个学生信息\n",current);printf("\n");printf("学生信息列表为:\n");printf("\n");for(i=0;i<current;i++){printf("第%d个学生信息如下:\n",i+1);printf(" 姓名: %s\n",stu[i].name);printf(" 学号: %s\n",stu[i].sno);printf(" 身份证号码: %s\n",stu[i].sid);printf(" 出生日期:%d-%d-%d\n",stu[i].birth.year,stu[i].birth.month,stu[i].birth.day);printf(" 地址:%s\n",stu[i].address);printf("\n");}return;}void save(){int count;FILE*fs;fs=fopen("studentdata.dat","wb");if(fs==NULL){printf("不能打开文件\n");return;}count=fwrite(stu,sizeof(struct student),current,fs);fclose(fs);if(count!=current){printf("保存失败\n");return;}printf("保存成功!\n");return;}void load(){FILE *fs;int count=0;int succ=0;fs=fopen("studentdata.dat","rb");if(fs==NULL){printf("不能打开文件!\n");return;}succ=fseek(fs,0,2);if(succ!=0){printf("文件操作失败!\n");return;}count=ftell(fs);fseek(fs,0,0);current=count/sizeof(struct student);stu=(struct student *)malloc(total*sizeof(struct student)); count=fread(stu,sizeof(struct student),current,fs);fclose(fs);if(count!=current){printf("读取文件失败\n");return;}printf("读取文件成功\n");return;}void main(){int choice;printf(" \n尊敬的用户您好,欢迎使用学生信息管理系统\n");printf("\n 1.进入系统后,先按“7”加载学生信息,再查询;\n");printf("\n 2.按照菜单提示输入数字代号;\n");printf("\n 3.增加学生信息后,切记保存按“6”;\n");printf("\n 4.谢谢您的使用!\n");printf("\n");printf("\n");printf("\n\t ****学****生****信****息****管****理****系****统*****\n");printf("\n");printf("\n");printf(" 主编:计算机应用班:第五组作品\n");printf("\n");printf(" 由胡磊,李文娟,冉琼,梁凯华,马立虎共同参与完成\n");printf("\n");printf("请您输入要录入的学生总人数:");scanf("%d",&total);while(1){printf("--------------------------------------------------------------------------------");printf(" ----------------------------");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\n");printf(" 请选择:");scanf("%d",&choice);printf("\n\n");switch(choice){case 1:insert();break;case 2:query();break;case 3:update();break;case 4:deiete();break;case 5:list();break;case 6:save();break;case 7:load();break;case 0:return;default:printf("非法选择请重新选择");}}}。
学生信息管理系统(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语言学生管理系统代码
struct scores *snext;
}stscores;
//宏定义学生个人信息
#define stmes (stmessage *)malloc(sizeof(stmessage)) //为学生个人信息结构体开辟动态内存空间
fflush(stdin);
s--;
}
switch(a)
{
case '1': mainmessage(); continue;//学生基本信息
case '2': mainresult();continue;//学生的成绩信息
case '3': exit(1);//退出系统
void xiugairesult();//修改学生成绩信息
void delatemessag1();//删除学生个人基本信息
void delatemessag2();//删除班级学生基本信息
void delatemessag3();//删除系基本信息
void delatemessag4();//删除全校基本信息
void ziresult4();//学生成绩信息修改菜单
void addmessage();//添加学生基本信息
void judgefile();//判断文件是否存在
void addresult();//添加学生成绩信息
void searchresult();//查询学生成绩信息
void readresult();//加载学生成绩信息到程序
//全局变量
stmessage *head=NULL;
stscores *shead=NULL;
学生信息管理系统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语言学生信息管理系统(附源码)
fclose(fp);
return;
}
printf("姓名:");
scanf("%s",stu[m].name);
printf("语文成绩:");
scanf("%f",&stu[m].chinese);
printf("数学成绩:");
scanf("%f",&stu[m].math);
char ch[2];
if((fp=fopen("stuData.txt","rb"))==NULL)
{
printf("打开文件失败\n");
return;
}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1)
m++;
fclose(fp);
if(m==0)
{
printf("文件无记录!\n");
default:printf("输入有误,请重新输入:");break;
}
getch();
menu();
scanf("%d",&n);
}
return 0;
}
/*******自定义函数实现菜单功能******/
void menu()
{
system("cls");
printf("\t\t|-------------学生信息系统----------|\n");
printf("\t\t| |\n");
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
学生信息管理系统C语言编程【问题描述】学生信息的管理是每个学校必须具有的管理功能,主要是对学生的基本情况及学习成绩等方面的管理。
该系统模拟一个简单的学生管理系统,要求对文件中所存储的学生数据进行各种常规操作,如:排序、查找、计算、显示等功能。
通过此课题,熟练掌握文件、数组、结构体的各种操作,在程序设计中体现一定的算法思想,实现一个简单的学生信息管理系统。
【基本要求】(1)学生信息包括:学生基本信息文件(student.txt)(注:该文件不需要编程录入数据,可用文本编辑工具直接生成)的内容如下:(2)学生成绩基本信息文件(score.dat)及其内容如下:((注:该文件内容需要编程录入数据,具体做法见下面的要求)学号课程编号课程名称学分平时成绩实验成绩卷面成绩综合成绩实得学分(3)需要实现的功能1)数据录入和计算功能:对score.dat进行数据录入,只录入每个学生的学号、课程编号、课程名称、学分、平时成绩、实验成绩、卷面成绩共7个数据,综合成绩、实得学分由程序根据条件自动运算。
综合成绩的计算:如果本课程的实验成绩为-1,则表示无实验,综合成绩=平时成绩*30%+卷面成绩*70%;如果实验成绩不为-1,表示本课程有实验,综合成绩=平时成绩*15%+实验成绩*15%+卷面成绩*70% 。
实得学分的计算:采用等级学分制,综合成绩在90-100之间,应得学分=学分*100%;综合成绩在80-90之间,应得学分=学分*80%;综合成绩在70-80之间 ,应得学分=学分*75%;综合成绩在60-70之间,应得学分=学分*60%;综合成绩在60以下 ,应得学分=学分*0%。
2)查询功能:分为学生基本情况查询和成绩查询两种(1)学生基本情况查询:①、输入一个学号或姓名(可实现选择),查出此生的基本信息并显示输出,格式如下:②、输入一个宿舍号码,可查询出本室所有的学生的基本信息并显示输出。
(格式如上所示)(2)成绩查询:①、输入一个学号时,查询出此生的所有课程情况,格式如下:学号:xx 姓名:xxxxx课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx课程编号:xxx 课程名称:xxxxx 综合成绩:xxxx 实得学分: xx ……………………共修:xx科,实得总学分为: xxx(3)删除功能:提供待删除学生的学号,则在student.txt和score.dat中删除所有与该学生有关的信息。
(4)排序功能:能实现选择按综合成绩或实得学分升序或降序排序并显示数据。
【程序设计的具体说明】(1)将与两个文件对应的信息分别定义两种结构体类型来表示,也可以用类来定义;(2)对score.dat文件的写入,从键盘上输入的是前七项,后两项数据项根据计算方法算出后,得到完整的结构体信息,作为一个整体写入(可调用write函数)。
(3)删除功能中可以将删除相关信息后得到的文件生成新文件存储,也可以在原文件的基础上作删除(4)可以用面向过程方法或是面向对象的方法实现。
(5)主界面提供菜单选择的方法选择实现某一功能,一次运行程序能进行多次选择执行不同的功能。
#include"stdio.h"#include"stdlib.h"#include"string.h"#define N 3typedef struct z1{char no[11];char name[15];int score[N];float sum;float average;int order;struct z1 *next;}STUDENT;STUDENT *init();STUDENT *create();STUDENT *del(STUDENT *h);void print(STUDENT *h);void search1(STUDENT *h);void search2(STUDENT *h);STUDENT *insert(STUDENT *h);void sort(STUDENT *h);void save(STUDENT *h);void tongji(STUDENT *h);int menu_select();STUDENT *load();void inputs(char *prompt,char *s,int count);STUDENT *load();main(){int i;STUDENT *head;head=init();for(;;){switch(menu_select()){case 0:head=init();break;case 1:head=create();break;case 2:head=insert(head);break;case 3:save(head);break;case 4:print(head);break;case 5:search1(head);break;case 6:head=del(head);break;case 7:sort(head);break;case 8:tongji(head);break;case 9:search2(head);break;case 10:exit(0);}}}int menu_select(){char *menu[]={"************菜单************", "0. 初始化链表","1. 输入学生成绩","2. 插入学生成绩","3. 保存学生记录","4. 显示学生记录","5. 按学号查找学生信息","6. 删除指定学号的学生信息","7. 按某一门课对学生成绩排序","8. 统计某门课程的学生成绩","9. 按姓名查找学生信息","10. 退出系统"};char s[3];int c,i;for(i=0;i<=11;i++)printf(" %s\n",menu[i]);do{printf("\n请选择0~10中的某一个选项\n"); scanf("%s",s);c=atoi(s);}while(c<0||c>10);return c;}STUDENT *init(){return NULL;}STUDENT *create(){int i;int s;STUDENT *h=NULL,*info;for(;;){info=(STUDENT *)malloc(sizeof(STUDENT));if(!info){printf("\n内存不足");return NULL;}inputs("输入学号:",info->no,11);if(info->no[0]=='@')break;inputs("输入姓名:",info->name,15);printf("开始输入%d门课的成绩\n",N);s=0;for(i=0;i<N;i++){do{printf("第%d门分数:",i+1);scanf("%d",&info->score[i]);if(info->score[i]>100||info->score[i]<0) printf("输入成绩错误,请重新输入:\n");}while(info->score[i]>100||info->score[i]<0); s=s+info->score[i];}info->sum=s;info->average=(float)s/N;info->order=0;info->next=h;h=info;}return h;}void inputs(char *prompt,char *s,int count){char p[255];do{printf(prompt);scanf("%s",p);if(strlen(p)>count)printf("\n太长了!\n");}while(strlen(p)>count);strcpy(s,p);}void print(STUDENT *h){int i=0;STUDENT *p;p=h;printf("\n\n\n***********************学生***********************\n");printf("|序号|学号 | 姓名 | 语文 | 英语 |数学 | 总分 |平均分 |名次|\n");printf("|---|-------|--------|----|----|----|------|------|---|\n");while(p!=NULL){i++;printf("|%3d|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",i,p->no,p->name,p->score[0],p->score [1],p->score[2],p->sum,p->average,p->order);p=p->next;}printf("***********************end***********************\n");}STUDENT *del(STUDENT *h){STUDENT *p,*q;char s[11];printf("请输入要删除的学生的学号\n");scanf("%s",s);q=p=h;while(strcmp(p->no,s)&&p!=NULL){q=p;p=p->next;}if(p==NULL)printf("\n链表中没有学号为%s的学生\n",s);else{printf("\n\n\n***********************找到了***********************\n"); printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次|\n");printf("|----------|----------|----|----|----|------|------|---|\n");printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);printf("***********************end***********************\n");printf("请按任意键删除\n");getchar();if(p==h)h=p->next;else q->next=p->next;free(p);printf("\n已经删除学号为%s的学生\n",s);printf("不要忘了保存数据\n");}return h;}void search1(STUDENT *h){STUDENT *p;char s[11];printf("请输入你要查找的同学的学号\n");scanf("%s",s);p=h;while(strcmp(p->no,s)&&p!=NULL)p=p->next;if(p==NULL)printf("'n没有学号为%s的学生\n",s);else{printf("\n\n\n***********************找到了***********************\n"); printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分| 名次 |\n");printf("|----------|-----------|----|----|----|------|------|---|\n");printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);printf("***********************end***********************\n");}}void search2(STUDENT *h){STUDENT *p;char s[11];printf("请输入你要查找的同学的姓名\n");scanf("%s",s);p=h;while(strcmp(p->name,s)&&p!=NULL)p=p->next;if(p==NULL)printf("\n没有姓名为%s的学生\n",s);else{printf("\n\n\n***********************找到了***********************\n"); printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");printf("|----------|-----------|----|----|----|------|------|---|\n");printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);printf("***********************end***********************\n");}}STUDENT *insert(STUDENT *h){STUDENT *p,*q,*info;char s[11];int s1,i;printf("请输入插入点的学生学号\n");scanf("%s",s);printf("\n请输入新的学生信息\n");info=(STUDENT *)malloc(sizeof(STUDENT));if(!info){printf("\n内存不足!");return NULL;}inputs("输入学号:",info->no,11);inputs("输入姓名:",info->name,15);printf("请输入%d门课的分数\n",N);s1=0;for(i=0;i<N;i++){do{printf("分数%d",i+1);scanf("%d",&info->score[i]);if(info->score[i]>100||info->score[i]<0)printf("输入数据有误,请重新输入\n");}while(info->score[i]>100||info->score[i]<0);s1=s1+info->score[i];}info->sum=s1;info->average=(float)s1/N;info->order=0;info->next=NULL;p=h;q=h;while(strcmp(p->no,s)&&p!=NULL){q=p;p=p->next;}if(p==NULL)if(p==h)h=info;else q->next=info;elseif(p==h){info->next=p;h=info;}else{info->next=p;q->next=info;}printf("\n已经插入了%s这个学生\n",info->name);printf("----不要忘了存盘啊--\n");return(h);}void save(STUDENT *h){FILE *fp;STUDENT *p;char out];printf("请输入保存文件的文件名,例如 c:\\f1\\te.txt:\n"); scanf("%s",outfile);if((fp=fopen(outfile,"wb"))==NULL){printf("不能打开文件\n");exit(1);}printf("\n正在保存......\n");p=h;while(p!=NULL){fwrite(p,sizeof(STUDENT),1,fp);p=p->next;}fclose(fp);printf("------保存成功!!!------\n");}void sort(STUDENT *h){int i=0,j;STUDENT *p,*q,*t,*h1;printf("请输入要按哪门课程的编号来排序:(0.语文 1.数学 2.英语)\n"); scanf("%d",&j);h1=h->next;h->next=NULL;while(h1!=NULL){t=h1;h1=h1->next;p=h;q=h;while(t->score[j]<p->score[j]&&p!=NULL){q=p;p=p->next;}if(p==q){t->next=p;h=t;}else{t->next=p;q->next=t;}}p=h;while(p!=NULL){i++;p->order=i;p=p->next;}print(h);printf("排序成功!!!\n");}void tongji(STUDENT *h){STUDENT *p;int a,b,i;printf("请输入课程编号\n");scanf("%d",&i);printf("请输入分数段:\n");scanf("%d,%d",&a,&b);p=h;while(p!=NULL){printf("\n\n\n***********************找到了***********************\n"); if(p->score[i]>=a&&p->score[i]<=b){printf("|学号 | 姓名 | 语文 | 英语 | 数学 | 总分 | 平均分 | 名次 |\n");printf("|--------|---------|----|----|----|------|------|---|\n");printf("|%-10s|%-8s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);}p=p->next;}printf("***********************end***********************\n");}。