C语言下简单的学籍管理系统源代码
学籍信息源代码
#include<stdio.h>#include<string.h>#define N 10struct date_type{int year;int month;}date;struct stud_type{char academy[10];char class1[10];int num;char name[10];char sex[4];struct date_type date;char address[10];int score[3];float average;int sum;int jilu;};struct stud_type stu[N];void duru(struct stud_type stu[]); /*数据读入*/void Add(struct stud_type stu[]); /*增加学生*/void Delete(struct stud_type stu[]); /*删除学生*/void Modify(struct stud_type stu[]); /*修改学生*/void Search(struct stud_type stu[]); /*查询学生*/void Print(struct stud_type stu[]); /*输出所有学生信息*/void Stat(struct stud_type stu[]); /*统计*/void Save(struct stud_type stu[]); /*数据存盘*/int r=0;void main(){int x;duru(stu);do{printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※欢迎使用本软件※\n");printf("※~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~※\n");printf("※指导老师:张老师※\n");printf("※※\n");printf("※制作者:黄同学※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~** \n");printf("******************学籍管理系统******************\n");printf("** **\n");printf("** 1.录入学生信息**\n");printf("****\n");printf("********* 2.修改学生信息*********\n");printf("****\n");printf("**** 3.查询学生信息****\n");printf("****\n");printf("************* 4.浏览所有学生信息**********\n");printf("****\n");printf("**** 5.删除学生信息****\n");printf("** **\n");printf("********* 6.综合统计*********\n");printf("** **\n");printf("**0.保存并退出系统**\n");printf("****\n");printf("**********************************************\n");printf("**----------------------------------------------- -----------------***\n");printf("请在0-6中选择: ");scanf("%d",&x);switch(x){case 1:Add(stu); /*录入模块*/break;case 2:Modify(stu); /*修改模块*/break;case 3:Search(stu); /*查询模块*/break;case 4:Print(stu); /*输出模块*/break;case 5:Delete(stu); /*删除模块*/break;case 6:Stat(stu); /*统计模块*/break;case 0:Save(stu);break;}}while(x!=0);}void Add (struct stud_type stu[]) /*录入模块*/{int i;char k;for(i=r;i<N;i++){printf("\n 请输入学院:");scanf("%s",stu[i].academy);printf("\n 请输入班级:");scanf("%s",stu[i].class1);printf("\n 请输入学号:");scanf("%d",&stu[i].num);printf("\n 请输入姓名:");scanf("%s",stu[i].name);printf("\n 请输入性别:");scanf("%s",stu[i].sex);printf("\n请输入出生年月:");scanf("%d%d",&stu[i].date.year,&stu[i].date.month);printf("\n 请输入地址:");scanf("%s",stu[i].address);printf("\n 请输入成绩:");scanf("%d%d%d",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);r=r+1;stu[i].sum=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];stu[i].average=stu[i].sum/3.0;printf("----------是否继续??(y/n):");scanf("%s",&k);if(k=='y'||k=='Y') continue;elseprintf("**********录入结束!**********\n\n");return;}}void Save(struct stud_type stu[]) /*保存模块*/{FILE *fp1; /*指向文件的指针*/int i;stu[0].jilu=r;if((fp1=fopen("E:\\xj.txt","wb"))==NULL) /*打开文件,并判断打开是否正常*/{printf("**********打开文件失败!**********\n\n");return;printf("开始存盘!\n");for(i=0;i<r;i++)if(fwrite(&stu[i],sizeof(struct stud_type),1,fp1)==0)printf("**********数据存盘失败!**********\n\n");fclose(fp1);printf("**********存盘成功!**********\n"); /*显示保存成功*/}void Search(struct stud_type stu[]) /*查询模块*/{int y=0,i,k;printf("请输入学号:");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num){printf("学院:%s\n班级:%s\n学号:%d\n姓名:%s\n性别:%s\n出生年月:%d%d\n地址:%s\n 成绩:\nC语言:%d高数:%d英语:%d\n",stu[i].academy,stu[i].class1,stu[i].num,stu[i].name,stu[i].sex,stu[i].date.year,stu[i].date. month,stu[i].address,stu[i].score[0],stu[i].score[1],stu[i].score[2]);y=1;}}if(y==0)printf("**********查无此人!**********\n\n");return;}void Delete(struct stud_type stu[]) /*删除模块*/{int i,j,k,y=0;int m=16899168,n;printf("请输入密码:");scanf("%d",&n);if(n==m);else{printf("**********密码错误!**********\n\n");return;}printf("请输入学号:");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num)for(j=i;j<r;j++)stu[j]=stu[j+1];r=r-1;printf("**********删除成功!**********\n\n");y=1;}}if(y==0)printf("**********查无此人!**********\n\n");}void Print(struct stud_type stu[]) /*输出模块*/ {int i,j,k,n;struct stud_type t;printf(" 1.按学号排序,2.按总分排序(由高到低)\n");printf("\n请在1和2中选择:");scanf("%d",&n);if(n==1) /*选择排序*/ for(i=0;i<r-1;i++){k=i;for(j=i+1;j<r;j++)if(stu[k].num>stu[j].num)k=j;if(k!=i){t=stu[i];stu[i]=stu[k];stu[k]=t;}}if(n==2)for(i=0;i<r-1;i++){k=i;for(j=i+1;j<r;j++)if(stu[k].sum<stu[j].sum)k=j;if(k!=i){t=stu[i];stu[i]=stu[k];stu[k]=t;}for(i=0;i<r;i++){printf("\n学院\t班级\t学号\t姓名\t性别\t出生年月\t地址\n");printf("%s\t%s\t%d\t%s\t%s\t%d %d\t\t%s\n",stu[i].academy,stu[i].class1,stu[i].num,stu[i].name,s tu[i].sex,stu[i].date.year,stu[i].date.month,stu[i].address);printf("C语言\t高数\t英语\t平均分\t总分\n");printf("%d\t%d\t%d\t%0.1f\t%d\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].average,stu[i ].sum);}}void Stat(struct stud_type stu[]) /*统计模块*/{int i,j,k;printf("0.C语言1.高数2.英语");printf("请在0-2中选择:");scanf("%d",&j);k=j;printf("90-100:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]>=90)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("80-90:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<90&&stu[i].score[k]>=80)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("70-80:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<80&&stu[i].score[k]>=70)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("60-70:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<70&&stu[i].score[k]>=60)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}printf("60分以下:\n");printf(" 学号\t姓名\t成绩\n");for(i=0;i<r;i++){if(stu[i].score[k]<60)printf(" %d\t%s\t%d\n",stu[i].num,stu[i].name,stu[i].score[k]);}}void Modify(struct stud_type stu[]) /*修改模块*/{int k,i,y=0;int m=16899168,n;printf("请输入密码:");scanf("%d",&n);if(n==m);else{printf("**********密码错误!**********\n\n");return;}printf("************修改学生信息************\n");printf("\n请输入要修改学生的学号: ");scanf("%d",&k);for(i=0;i<r;i++){if(k==stu[i].num){printf("\n请输入新内容:\n");printf("\n 请输入学院:");scanf("%s",stu[i].academy);printf("\n 请输入班级:");scanf("%s",stu[i].class1);printf("\n 请输入学号:");scanf("%d",&stu[i].num);printf("\n 请输入姓名:");scanf("%s",stu[i].name);printf("\n 请输入性别:");scanf("%s",stu[i].sex);printf("\n请输入出生年月:");scanf("%d%d",&stu[i].date.year,&stu[i].date.month);printf("\n 请输入地址:");scanf("%s",stu[i].address);printf("\n 请输入成绩:");scanf("%d%d%d",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);printf("\n**********修改成功!**********\n\n");y=1;}}if(y==0)printf("**********查无此人!**********\n\n");return;}void duru(struct stud_type stu[]) /*数据读入模块*/{int i;FILE *fp; /*指向文件的指针*/if((fp=fopen("E:\\xj.txt","rb"))==NULL) /*打开文件,并判断打开是否正常*/{printf("打开文件失败!\n");return;}printf("文件开始读取!\n");rewind(fp);for(i=0;i<=r;i++){fread(&stu[i],sizeof(struct stud_type),1,fp);r=stu[0].jilu;}printf("\n文件成功读取!\n");fclose(fp);r=stu[0].jilu;}。
学生管理系统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语言开发的学籍管理系统的源代码。
基本功能该学籍管理系统可以实现学生信息的录入、删除、修改和查询,以及学生的成绩录入、修改和查询。
此外,该系统还具备数据存储和文件读写的功能,能够自动保存学生信息和成绩数据,保障数据的安全性和可靠性。
模块设计该系统按照功能模块划分,主要分为三个模块:学生信息管理模块、学生成绩管理模块和数据存储与文件读写模块。
学生信息管理模块该模块主要实现学生信息的录入、删除、修改和查询等基本功能。
以下为该模块的主要源代码:```struct student {char name[20]; // 姓名int id; // 学号char sex[5]; // 性别char major[20]; // 专业};struct student stu[1000]; // 学生信息结构体数组int num_of_stu = 0; // 学生总数void add_student() { // 添加学生信息printf("请输入学生姓名:");scanf("%s", stu[num_of_stu].name);printf("请输入学生学号:");scanf("%d", &stu[num_of_stu].id);printf("请输入学生性别:");scanf("%s", stu[num_of_stu].sex);printf("请输入学生专业:");scanf("%s", stu[num_of_stu].major);num_of_stu++;printf("添加成功!\n");}void delete_student() { // 删除学生信息int delete_id;printf("请输入要删除的学生学号:");scanf("%d", &delete_id);int index = search_student_by_id(delete_id); if (index == -1) {printf("该学号不存在!\n");return;}for (int i = index; i < num_of_stu - 1; i++) { stu[i] = stu[i + 1];}num_of_stu--;printf("删除成功!\n");}void modify_student() { // 修改学生信息int modify_id;printf("请输入要修改的学生学号:");scanf("%d", &modify_id);int index = search_student_by_id(modify_id); if (index == -1) {printf("该学号不存在!\n");return;}printf("请输入学生姓名:");scanf("%s", stu[index].name);printf("请输入学生学号:");scanf("%d", &stu[index].id);printf("请输入学生性别:");scanf("%s", stu[index].sex);printf("请输入学生专业:");scanf("%s", stu[index].major);printf("修改成功!\n");}int search_student_by_id(int id) { // 根据学号查询学生信息for (int i = 0; i < num_of_stu; i++) {if (stu[i].id == id) {return i;}}return -1;}void query_student() { // 查询学生信息int query_id;printf("请输入要查询的学生学号:");scanf("%d", &query_id);int index = search_student_by_id(query_id);if (index == -1) {printf("该学号不存在!\n");return;}printf("姓名\t学号\t性别\t专业\n");printf("%s\t%d\t%s\t%s\n", stu[index].name,stu[index].id, stu[index].sex, stu[index].major);}```学生成绩管理模块该模块主要实现学生成绩信息的录入、修改和查询等功能。
c语言管理系统设计源代码
c语言管理系统设计源代码以下是一个简单的C语言管理系统示例,用于管理学生信息。
该系统可以添加、删除、修改和查找学生信息。
c复制代码#include<stdio.h>#include<stdlib.h>#include<string.h>struct student {char name[50];int roll;float marks;};struct student students[100];int count = 0;void add_student() {struct student new_student;printf("Enter name: ");scanf("%s", new_);printf("Enter roll number: ");scanf("%d", &new_student.roll);printf("Enter marks: ");scanf("%f", &new_student.marks);students[count] = new_student;count++;}void delete_student() {int index;printf("Enter index of student to delete: ");scanf("%d", &index);for (int i = index; i < count - 1; i++) {students[i] = students[i + 1];}count--;}void modify_student() {int index;struct student new_student;printf("Enter index of student to modify: "); scanf("%d", &index);printf("Enter new name: ");scanf("%s", new_);printf("Enter new roll number: ");scanf("%d", &new_student.roll);printf("Enter new marks: ");scanf("%f", &new_student.marks);students[index] = new_student;}void find_student() {char name[50];printf("Enter name of student to find: "); scanf("%s", name);for (int i = 0; i < count; i++) {if (strcmp(students[i].name, name) == 0) { printf("Roll number: %d\n", students[i].roll); printf("Marks: %.2f\n", students[i].marks); return;}}printf("Student not found.\n");}int main() {int choice;do {printf("\nMenu:\n");printf("1. Add student\n");printf("2. Delete student\n");printf("3. Modify student\n");printf("4. Find student\n");printf("5. Exit\n");printf("Enter choice: ");scanf("%d", &choice);switch (choice) {case1: add_student(); break;case2: delete_student(); break;case3: modify_student(); break;case4: find_student(); break;case5: exit(0); break; // exit the program here, otherwise the loop will keep running indefinitely, as it is in the do-while loop above. We are not returning, but rather exiting the program completely, so we do not need to return anything. The return value of main is always 0, and this is how the program exits. If you want to return a value other than 0, you can do so like this: return 1; or return -1; or return any other integer value you want to represent an error condition. The operating system will interpret this as the program's exit status. In this case, it will be seen as successful, as it is returning 0. The return value of main is not used for anything in this program, but it can be used in other programs to determine whether the program exited successfully or with an error. For example, if you were writing a shell script that executed this program and needed to know if it was successful or not, you could check the return value of the program and act accordingly. This is a common practice in programming, and it is important to understand how it works so that you can use it effectively in your own programs.。
C语言学籍管理系统(内含源代码)
学籍管理系统一、系统简介设计一个基于结构体数组的学生学籍管理系统,能实现对学生学籍信息进行录入,修改,删除,查询和输出等基本操作二、需求分析学籍管理系统应该实现以下功能:1、能录入学生的基本信息,包括学号,姓名,专业,年级,性别和出生日期信息,保存到结构体数组中。
2、能根据输入的学号查询学生,进行信息的修改。
3、能根据输入的学号从结构体数组中删除学生的记录。
4、实现查询功能,能根据输入的学号或年级在屏幕上显示相应的学生信息。
5、能在屏幕上以列表的方式输出所有学生的信息。
三、概要设计1、系统功能根据项目的开发要求,本系统划分成六个主要功能模块:录入学生信息模块、修改学生信息模块、删除学生信息模块、查询学生信息模块、输出模块和推出模块。
系统功能机构图如下:2、重要数据的数据结构设计学生学籍的记录项用结构体Stu message表示,包括6个属性,stuno,name、spec、grade、sex、birthday 分另U代表学生的学号、专业、年级、性另U和出生日期,其中birthday 类型为自定义的结构体类型Date.Struct stumessage {Char stuno[11]: // 学号Char name[9]: // 姓名Char spec[2]: // 专业Char grade: // 年级Char sex : // 性别Stuct date birthday: // 出生日期};日期类型date包括三个属性,分别代表年、月、日Struct date{int year : // 年Int month: //Int day: // H};3、函数设计学籍管理系统程序采用了结构化程序设计的思想,由1个.h 头文件和3个C源文件组成。
程序中除了主函数外,共设计了以下14个函数,分别包含在3个.c源文件中。
以下是这些函数原型及功能设计。
(1) void sysinfo(void)函数功能:在屏幕上输入系统及信息并等待用户响应。
学生管理系统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++编写学生信息管理系统源代码
int i=1;
char a[100];
ifstream ifs("已注册学号.txt",ios::in);
while(!ifs.eof())
{
ifs>>a;
if(strcmp(a,no)==0)
{
i=-1;
break;
}
}
return i;
}
int main()
{
end8:
cout<<"欢迎使用学生信息管理系统!"<<endl;
if(n==1)
{
int count=0;
system("cls");
end1:
cout<<"学生注册界面"<<endl;
cout<<endl;
cout<<endl;
char no[100],code[100];
char kong[100]=" ";
cout<<"请您注册"<<endl;
cout<<endl;
system("cls");
goto end17;
}
Sleep(600);
system("cls");
goto end1;
}
cout<<"密码:";
cin>>code;
cout<<endl;
ofstream ofs1("secret.txt",ios::out|ios::app);
用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语言的教务管理系统(2000行代码)
C语言教务管理系统一、程序结构图二、程序运行截图1. 个人信息简介2.修改颜色3.注册界面4. 信息保存至文件5.登录界面6.管理员录入信息7. 学生信息录入8.学生成绩录入9.学生课程表录入10.学生信息查询界面11学生信息查询12.学生成绩查询13.学生课表查询三、代码(一个cpp)#include<stdio.h> #include<stdlib.h> #include<string.h> #include<ctype.h> #include <conio.h>#include"windows.h"#define student_num 1000 /*定义1000个学生*/#define teacher_num 5 /*定义5个老师(管理员)*/int is_my_student(struct student *p,int *size); /*声明返回第i+1个学生的函数*/ int is_my_teacher(struct teacher *p,int *size); /*声明返回第i+1个老师的函数*/ int length_student_name(char *p); /*声明验证用户名函数*/int length_student_password(char *p); /*声明验证密码长度函数*/int length_teacher_name(char *p); /*声明验证用户名函数*/int length_teacher_password(char *p); /*声明验证密码长度函数*/int show_menu_login(); /*声明登录菜单函数*/int show_menu_register(); /*声明注册菜单函数*/int show_teacher_select(); /*声明教师录入菜单函数*/int show_student_select(); /*声明学生查询菜单函数*/int student_register(struct student *ptr_student,int *size); /*声明学生注册函数*/ int teacher_register(struct teacher *ptr_teacher,int *size); /*声明老师注册函数*/ int vaild_student_name(char *p); /*声明验证用户名函数*/int vaild_student_password(char *p); /*声明验证密码函数*/int vaild_teacher_name(char *p); /*声明验证用户名函数*/int vaild_teacher_password(char *p); /*声明验证密码函数*/int vaild_two_password(char *p1,char *p2); /*声明验证两次密码是否相同函数*/ int yes_no_return(); /*声明选择是否返回上一层函数*/void load(); /*声明加载函数*/void register_(int *count1,int *count2); /*声明注册函数*/void display_student(struct student stu); /*声明显示学生信息函数*/void display_teacher(struct teacher tea); /*声明显示老师信息函数*/void student_file1(); /*将保存的学生的账号密码存入文件中*/ void student_file2(); /*将保存的学生的个人信息存入文件中*/ void student_file3(); /*将保存的学生的成绩存入文件中*/void teacher_file(); /*将保存的老师的账号密码存入文件中*/ void input_information(int count); /*声明输入学生信息函数*/void input_score_menu(int count); /*声明输入学生成绩函数*/void color(); /*声明选择窗体颜色函数*/void print_stu_information(int count_stu); /*声明输出账号为num的学生的信息函数*/void print_stu_score(int count_stu); /*声明输出账号为num的学生的成绩函数*/void show_menu(); /*声明初始化界面函数*/void input(); /*声明输入函数*/void menu1(); /*声明教师录入课程表主菜单函数*/void menu2(); /*声明学生查询课程表主菜单函数*/void rank(); /*声明显示时间顺序函数*/void querymenu3(); /*声明查询函数*/void looktime(); /*声明按照时间查询函数*/void looklessonname(); /*声明按照课程名查询函数*/void add(); /*声明保存函数*/void amend(); /*声明修改课程函数*/void amend1(); /*声明修改课程子函数*/void amendnews(int i); /*声明修改整个课程信息函数*/void amendtime(int i); /*声明修改课程时间函数*/void amendlessonname(int i); /*声明修改课程课程名函数*/void amendclassroom(int i); /*声明修改课程教室函数*/void deleted(); /*声明删除函数*/void add_score(int count); /*声明添加学生成绩函数*/void xiugai_score(int count); /*声明修改学生成绩函数*/void shanchu_score(int count); /*声明删除学生成绩函数*/void chaxun_score(int count); /*声明按要求查询学生成绩函数*/void paixu_score(int count); /*声明学生成绩排序函数*/void tongji_score(int count); /*声明学生成绩统计函数*/float chinese(int count); /*声明计算语文成绩最大值函数*/int chr(int count); /*声明计算语文成绩及格人数的函数*/ float english(int count); /*声明计算英语成绩最大值函数*/int ehr(int count); /*声明计算英语成绩及格人数的函数*/ float math(int count); /*声明计算数学成绩最大值函数*/int mhr(int count); /*声明计算数学成绩及格人数的函数*/ float computer(int count); /*声明计算计算机成绩最大值函数*/int thr(int count); /*声明计算计算机成绩及格人数的函数*/float PE(int count); /*声明计算体育成绩最大值函数*/int phr(int count); /*声明计算体育成绩及格人数的函数*/ float sum_score(int count); /*声明计算总分成绩最大值函数*/ void load_student(int a); /*声明启动学生函数*/void load_teacher(int a); /*声明启动老师函数*/struct student /*学生结构体*/{/*个人信息*/int student_id; /*账号*/char student_name[20]; /*姓名*/char password[16]; /*密码*/int age; /*年龄*/char qq[12]; /*QQ号*/char tel[12]; /*电话*/int grade; /*年级*//*各科成绩*/float chinese; /*语文分数*/float english; /*英语分数*/float math; /*数学分数*/float computer; /*计算机分数*/float PE; /*体育分数*/float sum; /*总分*//*课程表*/char time[10]; /*时间*/char lessonname[20]; /*课程名*/char teacher[20]; /*授课老师*/char classroom[10]; /*教室*/char hours[10]; /*第几节课*/int weeks; /*周时*/};struct teacher /*老师结构体*/ {int teacher_id; /*账号*/char teacher_name[20]; /*姓名*/char password[16]; /*密码*/};struct student our_student[student_num]; struct teacher our_teacher[teacher_num];void main() /*主函数*/{system("color f0"); /*初始化背景颜色*/show_menu(); /*制作人信息简介*/load();}void load() /*启动函数*/{int flag=1; /*控制循环结束的变量*/int a=0,b=0; /*记录已注册的学生的人数a为学生个数b为老师个数*/int *count1=&a,*count2=&b; /*指向学生人数和老师人数的指针*/int correct_student,correct_teacher;color();register_(count1,count2); /*注册学生和老师的帐号*/student_file1();teacher_file();while(flag){switch(show_menu_login()) /*显示登录菜单*/{case 1: /*选择1,进入学生登录*/if(correct_student=is_my_student(our_student,count1)){printf("\n ◆学生登录成功!\n");display_student(our_student[correct_student-1]);printf("\n");printf(" ");system("pause");load_student(a);}elseprintf("\n登录失败!\n");printf("\n");printf(" 提示:按Y退出登录界面,按N返回登录界面!!!\n");flag=yes_no_return();system("cls");break;case 2: /*选择2,进入老师登录,即管理员登录*/ if(correct_teacher=is_my_teacher(our_teacher,count2)){printf("\n ◆管理员登录成功!\n");display_teacher(our_teacher[correct_teacher-1]);printf("\n");printf(" ");system("pause");load_teacher(a);}elseprintf("\n登录失败!\n");printf("\n");printf(" 提示:按Y退出登录界面,按N返回登录界面!!!\n");flag=yes_no_return();system("cls");break;case 3: /*选择3,退出登录*/system("cls");flag=0;break;default:printf("请正确输入1-3:");system("cls");}}}void load_student(int a) /*启动学生函数*/{int flag=1;system("cls");while(flag){switch(show_student_select()){case 1: /*选择1,学生信息查询*/system("cls");print_stu_information(a);printf("\n");printf(" 提示:按Y退出学生查询界面,按N返回学生查询界面!!!\n");flag=yes_no_return();system("cls");break;case 2: /*选择2,学生成绩查询*/system("cls");print_stu_score(a);printf("\n");printf(" 提示:按Y退出学生查询界面,按N返回学生查询界面!!!\n");flag=yes_no_return();system("cls");break;case 3: /*选择3,学生课表查询*/menu2();printf(" 提示:按Y退出学生查询界面,按N返回学生查询界面!!!\n");flag=yes_no_return();system("cls");break;case 4: /*选择4,退出查询界面*/system("cls");flag=0;break;default:printf("请正确输入1-4:");system("cls");}}}void load_teacher(int a) /*启动老师函数*/{int flag=1;system("cls");while(flag){switch(show_teacher_select()){case 1: /*选择1,学生信息录入*/input_information(a);system("cls");student_file2();printf("\n 提示:按Y退出教师录入界面,按N返回教师录入界面!!!\n");flag=yes_no_return();system("cls");break;case 2: /*选择2,学生成绩录入*/input_score_menu(a);system("cls");student_file3();printf("\n 提示:按Y退出教师录入界面,按N返回教师录入界面!!!\n");flag=yes_no_return();system("cls");break;case 3: /*选择3,学生课表录入*/menu1();printf(" 提示:按Y退出教师录入界面,按N返回教师录入界面!!!\n");flag=yes_no_return();system("cls");break;case 4: /*选择4,退出管理界面*/system("cls");flag=0;break;default:printf("请正确输入1-4:");system("cls");}}}int length_student_name(char *p) /*验证用户名是否合法*/ {int l;l=strlen(p);if(l>20||l<1)return 0;elsereturn 1;}int vaild_student_name(char *p) /*判断用户名是否有效*/{int i=0;int len=strlen(p);if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')) /*判断首字母是不是字母*/ {for(i=0;i<len;i++){if(!(p[i]='_'||(p[i]>='a'&&p[i]<='z')||(p[i]>='A'&&p[i]<='Z')||(p[i]>='0'&&p[i]<=' 9'))) /*判断后面的字符是否有效*/return 0;}return 1;}elsereturn 0;}int length_student_password(char *p) /*密码长度有效性验证*/{int len;len=strlen(p);if(len<6||len>16)return 0;elsereturn 1;}int vaild_student_password(char *p) /*密码的有效性验证*/{int i=0;for(;*p!='\0';p++){if(!((*p>='a'&&*p<='z')||(*p>'A'&&*p<'Z')||(*p>='0'&&*p<='9'))) return 0;}return 1;}int vaild_two_password(char *p1,char *p2) /*验证两次密码是否相同*/{if(strcmp(p1,p2)==0)return 1;elsereturn 0;}int student_register(struct student *ptr_student,int *size) /*完成注册功能*/{char password[16];char repassword[16];if(*size==student_num){puts(" ◆注册人数已满!");printf("\n");return 0;}system("cls");printf("\n\n");printf(" ★请输入注册学生姓名:");fflush(stdin);gets(ptr_student[*size].student_name);if(!(length_student_name(ptr_student[*size].student_name)&&vaild_student_name(ptr_student[*size].student_name))){printf(" ◆您输入的姓名无效,学生姓名在1-20之间,首字符为字母,后面必须为字母、数字或下划线!!!");return 0;}printf("\n");printf(" ★请输入注册密码:");fflush(stdin);gets(password);printf("\n");printf(" ★请再次输入注册密码:");fflush(stdin);gets(repassword);printf("\n");if(!vaild_two_password(password,repassword)){printf("\n №:两次输入的密码不一致!!!");printf("\n");return 0;}elsestrcpy(ptr_student[*size].password,password);if(!(length_student_password(ptr_student[*size].password)&&vaild_student_pa ssword(ptr_student[*size].password))){printf(" ◆您输入的密码无效,密码应在6-16位之间,密码只能包含字母和数字!!!");printf("\n");return 0;}printf(" ★您的编号为:%d,这将是您的登录账号!!!",ptr_student[*size].student_id=20150000+*size);return 1;}int is_my_student(struct student *p,int *size) /*如果登录成功则返回第i+1个学生的信息,否则返回0*/{int i;int zhanghao;char mima[18];system("cls");printf("\n\n");printf(" ★请输入您的账号:");scanf("%d",&zhanghao);fflush(stdin);printf("\n");printf(" ★请输入您的密码:");gets(mima);for(i=0;i<*size;i++){if((zhanghao==p[i].student_id)&&(strcmp(mima,p[i].password)==0)) return i+1;}return 0;}void display_student(struct student stu) /*显示学生信息*/{printf("\n ★您的账号是:%d\n",stu.student_id);}int length_teacher_name(char *p) /*验证用户名是否合法*/{int l;l=strlen(p);if(l>20||l<1)return 0;elsereturn 1;}int vaild_teacher_name(char *p) /*判断用户名是否有效*/{int i=0;int len=strlen(p);if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')) /*判断首字母是不是字母*/ {for(i=0;i<len;i++){if(!(p[i]='_'||(p[i]>='a'&&p[i]<='z')||(p[i]>='A'&&p[i]<='Z')||(p[i]>='0'&&p[i]<=' 9'))) /*判断后面的字符是否有效*/return 0;}return 1;}elsereturn 0;}int length_teacher_password(char *p) /*密码长度有效性验证*/{int len;len=strlen(p);if(len<6||len>16)return 0;elsereturn 1;}int vaild_teacher_password(char *p) /*密码的有效性验证*/{int i=0;for(;*p!='\0';p++){if(!((*p>='a'&&*p<='z')||(*p>'A'&&*p<'Z')||(*p>='0'&&*p<='9'))) return 0;}return 1;}int teacher_register(struct teacher *ptr_teacher,int *size) /*完成注册功能*/{char password[16];char repassword[16];if(*size==teacher_num){puts(" ◆注册人数已满!");printf("\n");return 0;}system("cls");printf("\n\n");printf(" ★请输入注册教师姓名:");fflush(stdin);gets(ptr_teacher[*size].teacher_name);if(!(length_teacher_name(ptr_teacher[*size].teacher_name)&&vaild_teacher_na me(ptr_teacher[*size].teacher_name))){printf(" ◆您输入的姓名无效,教师姓名在1-20之间,首字符为字母,后面必须为字母、数字或下划线!!!");printf("\n");return 0;}printf("\n");printf(" ★请输入注册密码:");fflush(stdin);gets(password);printf("\n");printf(" ★请再次输入注册密码:");fflush(stdin);gets(repassword);printf("\n");if(!vaild_two_password(password,repassword)){printf("\n №:两次输入的密码不一致!!!");printf("\n");return 0;}elsestrcpy(ptr_teacher[*size].password,password);if(!(length_teacher_password(ptr_teacher[*size].password)&&vaild_teacher_password(ptr_teacher[*size].password))){printf(" ◆您输入的密码无效,密码应在6-16位之间,密码只能包含字母和数字!!!");printf("\n");return 0;}printf(" ★您的编号为:%d,这将是您的登录账号。
学生信息管理系统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);}}。
学籍信息管理系统设计源代码
#include<stdio.h>#define N 50#define M 200int stumax=0,scoremax=0;FILE *fp;struct student{char num[9]; //学号char name[20]; //姓名int sex; //性别int room; //宿舍号码long int tel;//电话号码}stu[N];struct stuscore{char num[9];//学号char coursenum[10];//课程编号char course[15];//课程名称float point;//学分int nscore;//平时成绩int expscore; //实验成绩int examscore;//卷面成绩int comscore; //综合成绩float getpoint;//实得学分}score[M],score1[M];void enter_stu();void input_stu(int j);void enter_score();void input_score(int i);void com_score(int i);void browse_stu();void browse_score();void search();void search_stu();void search_num();void search_name();void search_room();void search_score();void printf_onestu_score(char snum[]);void delete_one();void order();void order_course_num();void order_course();void order_printf(int k);/***********菜单***********/void menu(){int w1;char n;/*变量n保存选择菜单数字,w1判断输入的数字是否在功能菜单对应数字范围内*/system("cls");do{puts(”****************************************************************\n\n”);puts("\t ***************** 总菜单*****************\n\n”);puts("\t***1。
课程设计:学生学籍管理系统源代码
#include”stdio。
h”#include"conio。
h”#include"stdlib。
h”#include”string。
h"#define N 1000 //N为可输入的学生总人数,可根据需要更改#define M 2 //M为宏定义的(在创建密码函数中)可建立的登陆用户个数,可更改struct student //定义学生信息结构体数组{char num[9]; //学号char name[20]; //姓名char depar[15]; //院系char zhuanye[15];//专业char classes[5]; //班级char age[3];//年龄char sex[4]; //性别char nation[5]; //民族char birth[9]; //出生日期char add[10];//籍贯};struct code //定义密码结构体数组{char name[20];char code[7];}co[M],s0;//确认是否新创建密码文件模块int code(){FILE *fp;if((fp=fopen("学生学籍管理系统__code。
txt","rt"))==NULL){printf(”密码文件不存在,请输入新的用户名及密码:\n");//若不存在此密码文件,则提示用户创建密码printf("请输入任意键继续!”);getch();system("cls");return 1; //无密码文件返回1 }elsereturn 0; //已有密码文件返回0 }//新创建初始密码void code_input(){FILE *fp;int i;if((fp=fopen(”学生学籍管理系统__code。
txt”,"wt"))==NULL);//当建立密码文件成功时,进入for循环for(i=0;i〈M;i++) //M为宏定义的可建立的登陆用户个数,可更改{printf("请录入第%d个用户名:",i+1);//创建不同的用户名及密码scanf(”%s",co[i]。
学生信息管理系统c语言代码
学生信息管理系统c语言代码以下是一个简单的学生信息管理系统的 C 语言代码示例,包含了学生信息的添加、查询、修改和删除功能。
由于代码超过了 400 字,我将提供一个简化的版本,你可以根据需要进行扩展和改进。
```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_STUDENTS 100// 学生结构体struct Student {char id[10];char name[50];int age;};// 学生信息列表struct Student students[MAX_STUDENTS];// 学生数量int studentCount = 0;// 添加学生信息void addStudent() {if (studentCount >= MAX_STUDENTS) {printf("学生数量已满,无法添加更多学生。
\n");return;}printf("请输入学生 ID: ");scanf("%s", students[studentCount].id);printf("请输入学生姓名: ");scanf("%s", students[studentCount].name);printf("请输入学生年龄: ");scanf("%d", &students[studentCount].age);studentCount++;printf("学生信息添加成功。
\n");}// 查询学生信息void queryStudent() {if (studentCount == 0) {printf("没有学生信息可供查询。
学籍管理系统c语言源代码
学籍管理系统C语言源代码1. 引言学籍管理系统是一种用于管理学生学籍信息的软件系统,它可以方便地对学生的个人信息、课程成绩、考试排名等进行管理和查询。
C语言是一种广泛应用于软件开发领域的编程语言,其简洁高效的特点使其成为学籍管理系统开发的理想选择。
本文将从学籍管理系统的需求分析、设计思路、主要功能实现和源代码解释等方面进行详细讨论。
2. 需求分析学籍管理系统的主要需求包括学生信息管理、课程管理和成绩管理等功能。
具体要求如下: 1. 学生信息管理:包括学生基本信息(姓名、性别、年龄、籍贯等)和学籍信息(学号、入学年份、班级等)的录入和查询。
2. 课程管理:包括课程信息(课程名称、学分、教师等)的录入和查询。
3. 成绩管理:包括学生成绩的录入和查询,并能计算每个学生的GPA(平均绩点)和排名。
3. 设计思路学籍管理系统的设计思路可以分为三个模块:学生信息管理模块、课程管理模块和成绩管理模块。
每个模块都有自己的功能,通过相互调用实现系统的完整功能。
3.1. 学生信息管理模块学生信息管理模块主要实现学生信息的录入和查询功能。
录入学生信息时,系统会要求输入学生的姓名、性别、年龄、籍贯等信息,并为学生分配一个唯一的学号。
以下是学生信息管理模块的伪代码示例:struct Student {int id;char name[20];char gender[10];int age;char hometown[50];};void addStudent(struct Student* student) {// 输入学生信息并存储到学生结构体中}void queryStudent(int id) {// 根据学号查询学生信息并输出}3.2. 课程管理模块课程管理模块主要实现课程信息的录入和查询功能。
录入课程信息时,系统会要求输入课程的名称、学分、教师等信息。
以下是课程管理模块的伪代码示例:struct Course {char name[50];int credit;char teacher[20];};void addCourse(struct Course* course) {// 输入课程信息并存储到课程结构体中}void queryCourse(char* name) {// 根据课程名称查询课程信息并输出}3.3. 成绩管理模块成绩管理模块主要实现学生成绩的录入和查询功能,并能计算每个学生的GPA和排名。
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语言学生信息管理系统(附源码)
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)。
#include <stdio.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#include <conio.h>#define N 10000void window();typedef struct student{char ID[10];char name[20];char sex;float score[5];float total;float ag;} STU;FILE *fp;STU stu[N];STU stu1[N];void tj(int i){int j,k,m=0,flag=0,n=0,flag1;printf("请输入第%d个学生信息\n",i+1);do{flag=0;printf("请输入学生学号(学号小于9位数字组成)\n");scanf("%s",&stu[i].ID);for(k=i-1; k>=0; k--)if(strcmp(stu[k].ID,stu[i].ID)==0){printf("输入错误,请重新输入\n");flag=1;break;}if(strlen(stu[i].ID)>8){printf("输入错误,请重新输入\n");flag=1;}for(k=0; k<n; k++)if(strcmp(stu1[k].ID,stu[i].ID)==0){printf("输入错误,请重新输入\n");flag=1;break;}}while(flag);do{flag=0;printf("请输入学生姓名\n");scanf("%s",stu[i].name);}while(flag);do{getchar();printf("请输入学生性别(f或m f代表女性m代表男性)\n");scanf("%c",&stu[i].sex);if((stu[i].sex)!='f'&&(stu[i].sex)!='m'){printf("输入错误,请重新输入\n");flag=1;}else flag=0;}while(flag);printf("请输入五门课成绩(输入成绩无顺序,成绩0~100)\n"); printf("每次只输入一门\n");stu[i].total=0;for(j=0; j<5; j++){do{printf("输入第%d科",j+1);scanf("%f",&stu[i].score[j]);if(stu[i].score[j]<0.0||stu[i].score[j]>100.0){flag1=1;printf("第%d科成绩输入错误,请重新输入\n",j+1);}elseflag1=0;stu[i].total=stu[i].total+stu[i].score[j];}stu[i].ag=stu[i].total/5;}}void add(){int i=0,j,n=0,be;char ch;if((fp=fopen("d:\\student.dat","a+"))==NULL){printf("打开文件失败\n");system("pause");window();}for(i=0; fread(&stu1[i],sizeof(STU),1,fp)!=0; i++);be=n=i;fclose(fp);while(1){tj(n++);printf("是否继续添加(yes--y or Y,no--others)\n");getchar();scanf("%c",&ch);if(ch!='y'&&ch!='Y') break;}if((fp=fopen("d:\\student.dat","a"))==NULL){printf("打开失败\n");exit(0);}for(i=be; i<n; i++)if (fwrite(&stu[i],sizeof(struct student),1,fp)!=1)printf("文件保存失败\n");fclose(fp);window();}void output(){int i,j,m;i=0;if((fp=fopen("d:\\student.dat","r"))==NULL){printf("文件打开失败\n");system("pause");}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);m=i;if(m==0)printf("无学生记录文件\n");else{for(i=0; i<m; i++){printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f",stu[i].total);printf("%8.2f",stu[i].ag);printf("\n");}}system("pause");fclose(fp);window();}void edit(){int i,j,flag,n;char ch,ch1,num[10];flag=1;printf("请输入需要修改的学生学号:");scanf("%s",num);if((fp=fopen("d:\\student.dat","r"))==NULL){printf("文件打开失败\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(struct student),1,fp)!=0; i++);n=i;fclose(fp);do{for(i=0; i<n; i++)if(strcmp(num,stu[i].ID)==0){flag=0;printf("修改位置的原记录为:\n");printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f%8.2f",stu[i].total,stu[i].ag);printf("\n");printf("是否修改姓名?\n");printf("请输入y or n:\n");ch=getch();if(ch=='y'){printf("请输入姓名:\n");scanf("%s",stu[i].name);}printf("是否修改性别?\n");printf("请输入y or n:\n");ch=getch();if(ch=='y'){printf("请输入f or m:\n") ;getchar();scanf("%c",&stu[i].sex);}printf("是否修改成绩?\n");printf("input y\\n:\n");ch=getch();if(ch=='y'){stu[i].total=0;for(j=0; j<5; j++){printf("输入学科成绩%d:\n",j+1);scanf("%f",&stu[i].score[j]);stu[i].total=stu[i].total+stu[i].score[j];}stu[i].ag=stu[i].total/5;}break;}if(flag)printf("输入学号错误!\n");printf("是否继续修改?(yes--y or Y,no--others)\n");getchar();ch1=getchar();}while(ch1=='y'||ch1=='Y');rewind(fp);if((fp=fopen("d:\\student.dat","w"))==NULL){printf("打开文件失败!\n");exit(0);}for(i=0; i<n; i++)fwrite(&stu[i],sizeof(struct student),1,fp);fclose(fp);window();}void px3(){int a,b,c,d,i=0,n=0,j;STU stu2;if((fp=fopen("d:\\student.dat","r"))==NULL){printf("文件打开失败!\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;fclose(fp);for(a=0; a<n; a++)for(b=0; b<n-a-1; b++)if(strcmp(stu[b].name,stu[b+1].name)>0){stu2=stu[b];stu[b]=stu[b+1];stu[b+1]=stu2;}for(i=0; i<n; i++){printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f",stu[i].total);printf("%8.2f",stu[i].ag);printf("\n");}system("pause");window();}void delete_all(){char ch1;printf("是否全部删除?(yes--y or Y,no--others)\n");getchar();scanf("%c",&ch1);if(ch1=='y'||ch1=='Y'){if((fp=fopen("d:\\student.dat","w"))==NULL) {printf("打开文件失败!\n");system("pause");window();}printf("全部删除成功!\n");}printf("按任意键返回\n");getch();fclose(fp);window();}void delete_one(){int i,j,flag,n;char s[10];char ch;if ((fp=fopen("d:\\student.dat","r"))==NULL){printf("打开文件失败!");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;fclose(fp);do{printf("\n请输入要删除的学生学号:");scanf("%s",s);for(flag=1,i=0; flag&&i<n; i++){if(strcmp(s,stu[i].ID)==0){printf("删除学生原信息:\n");printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f%8.2f",stu[i].total,stu[i].ag);printf("\n");if(i==n-1){n--;flag=0;}else{for(j=i; j<n-1; j++)stu[j]=stu[j+1];flag=0;n--;}}}if (flag==0)printf("\n 学生信息已删除\n");elseprintf("\n 要删除学生不存在\n");printf("是否继续删除?(yes-y,no-others)\n");getchar();ch=getchar();}while(ch=='y'||ch=='Y');if((fp=fopen("d:\\student.dat","w"))==NULL){printf("打开文件失败!\n");exit(0);}for(i=0; i<n; i++)fwrite(&stu[i],sizeof(struct student),1,fp);fclose (fp);window();}void px1(){int a,b,c,d,i=0,n=0,j;STU stu2;if((fp=fopen("d:\\student.dat","r"))==NULL){printf("文件打开失败!\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;fclose(fp);for(a=0; a<n; a++)for(b=0; b<n-a-1; b++)if(stu[b].total>stu[b+1].total){stu2=stu[b];stu[b]=stu[b+1];stu[b+1]=stu2;}for(i=0; i<n; i++){printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f",stu[i].total);printf("%8.2f",stu[i].ag);printf("\n");}system("pause");window();}void px2(){int a,b,c,d,i=0,n=0,j;STU stu2;if((fp=fopen("d:\\student.dat","r"))==NULL){printf("文件打开失败!\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;fclose(fp);for(a=0; a<n; a++)for(b=0; b<n-a-1; b++)if(stu[b].total<stu[b+1].total){stu2=stu[b];stu[b]=stu[b+1];stu[b+1]=stu2;}for(i=0; i<n; i++){printf("%8s%8s%4s%8s%8s%8s%8s%8s%8s%8s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%8s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%8.2f",stu[i].score[j]);printf("%8.2f",stu[i].total);printf("%8.2f",stu[i].ag);printf("\n");}system("pause");window();}void cz1(){int flag,i,j,n,flag1;char ch,str[10];if((fp=fopen("d:\\student.dat","r"))==NULL){printf("打开文件失败!\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;do{flag1=0;printf("请输入学号:\n");scanf("%s",str);for(i=0; i<n; i++)if(strcmp(stu[i].ID,str)==0){printf("已找到!\n");printf("该学生信息:\n");flag1=1;printf("%9s%8s%4s%7s%7s%7s%7s%7s%7s%7s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%9s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%7.2f",stu[i].score[j]);printf("%7.2f%7.2f",stu[i].total,stu[i].ag);printf("\n");}if(flag1==0)printf("学生信息不存在!\n");printf("是否继续查找?(yes-y or Y,no-others)\n");getchar();scanf("%c",&ch);if((ch=='Y')||(ch=='y'))flag=1;elseflag=0;}while(flag);fclose(fp);window();}void cz2(){int flag,i,j,n,flag1;char ch,str[10];if((fp=fopen("d:\\student.dat","r"))==NULL){printf("打开文件失败!\n");system("pause");window();}for(i=0; fread(&stu[i],sizeof(STU),1,fp)!=0; i++);n=i;do{flag1=0;printf("请输入学生姓名:\n");scanf("%s",str);for(i=0; i<n; i++)if(strcmp(stu[i].name,str)==0){printf("已找到!\n");printf("该学生信息:\n");flag1=1;printf("%9s%8s%4s%7s%7s%7s%7s%7s%7s%7s\n","ID","NAME","SEX","SCORE1","SCORE 2","SCORE3","SCORE4","SCORE5","TOTAL","AG");printf("%9s%8s%4c",stu[i].ID,stu[i].name,stu[i].sex);for(j=0; j<5; j++)printf("%7.2f",stu[i].score[j]);printf("%7.2f%7.2f",stu[i].total,stu[i].ag);printf("\n");}if(flag1==0)printf("学生信息不存在!\n");printf("是否继续查找?(yes-y or Y,no-others)\n");getchar();scanf("%c",&ch);if((ch=='Y')||(ch=='y'))flag=1;elseflag=0;}while(flag);fclose(fp);window();}void window(){system("cls");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("8、删除学生信息(一个学生)\n");printf("9、删除学生信息(全部学生)\n");printf("10、输出文件信息\n");printf("11、退出\n");int a;scanf("%d",&a);if(a==1)add();if(a==2)edit();if(a==3)px1();if(a==4)px2();if(a==5)px3();if(a==6)cz2();if(a==7)cz1();if(a==8)delete_one();if(a==9)delete_all();if(a==10)output();if(a==11)return;}int main(){window();}。