目录
1.系统功能分析
1.1系统信息要求
1.2功能分析
1.3奖学金评选标准
2.系统设计
3.运行效果图
4.测试数据:
5.文件说明:
6.源代码
1)学生基本信息如下:
学号、姓名、宿舍号、性别、年龄;
学号为标准格式1234567890十位,其中前两位代表学生入学年份,3-4位代表学生所在学院,5-6位代表学生所学专业、7-8位代表学生所在班级,9-10位代表学生在班级中的序号。
姓名最多为4个汉字;
性别为“男”或“女”;
年龄为2位正整数
2)课程信息如下:
课程号、课程类别、课程所在学期、课程名称、学分;
课程号为标准课号。例如B08010100;
课程类别为:选修/必修
所在学期用阿拉伯数字1-8代表
课程名称为专业为2014版人才培养计划中的课程名称
3)学生成绩信息如下:
学号、课程号、课程成绩、是否重修
学号为学生信息中的主关键字,可以唯一识别学生。课程号为课程信息的主关键字,可以唯一识别课程。是否重修用于判断课程成绩是否是第一次考试取得。
4)综合信息
学号、姓名、获奖类别、获奖时间、惩处类别、惩处时间、所获学分、奖励分值、惩罚分值。奖惩分起始值均为0分。
1.2.1录入部分
1)能实现学生信息的录入、修改并保存;
2)能实现课程信息的录入、修改并保存;
3)能分学期录入品行表现成绩(辅导员、班主任、班级评议)、修改并保存
4)能实现课程成绩的录入,并且在实现某课程成绩录入时,能够自动按学号排好顺序,并提示“某学号、某同学 某门功课成级”,例如“1508100201 丁兆元 C语言程序设计A成绩”。
5)能录入学生的各种奖惩信息
1.2.2修改部分
1)能对录入的课程成绩进行修改,例如成绩录错、重考、重修原因引起的成绩更改等。
2)能对个人信息进行修改
3)能对课程信息进行修改
4)能对学生奖惩信息进行修改
1.2.3统计分析部分
1)能对某门功课各分数段成绩进行统计
2)能分学期对学生业务课程平均分按分数段进行统计
3)能统计任意一名同学每门功课的班级排名以及业务课成绩总体排名
4)能以宿舍为单位进行成绩统计分析
5)能以挂科次数为依据分学期对比分析
6)能以业务课班级排名为依据分学期对比分析(前进或退步情况)
1.2.4排序部分
1)分学期按业务课程成绩对学生由高到低排序,并显示业务成绩平均分。
2)分学期按不及格门次对学生由高到低排序,并显示不及格门次。
3)分学期按不及格学生数对课程进行由高到低排序,并显示课程名及不及格学生数。
4)能分学期以宿舍为单位按成绩由高到低进行排序,并显示宿舍平均成绩。
5)能随时根据奖励对学生进行由高到低排序并输出信息。
6)能随时根据惩罚情况对学生由低到高排序并输出信息。
1.2.5奖学金自动评定
能根据学校奖学金评选办法,分学期进行奖学金评定并显示,并能够将评选结果自动追加到学生的奖惩信息库。
1.2.6数据的导入导出
基础数据一次录入永久存放,在需要时导入内存变量,如有修改重新导入文件,使永久保存的数据与临时使用的数据保持一致性。
1.3.1奖学金评选资格。有下列情形之一者,不能获得奖学金:
1)品行表现测评名次在班级70%以后者;
2)必修课或选修课有不及格者;
3)未达到《大学生体育锻炼合格标准》者;
4)受警告以上处分者,半年或察看期内不得参加奖学金评选;
5)品行表现具有不宜获得奖学金的其他情形者。
1.3.2综合奖学金的评选
该奖项用于奖励品学兼优、素质全面发展的优秀学生。
(1)奖励等级、金额、比例为:
特等奖2000元/人•年 3‰
一等奖1200元/人•年 3%
二等奖700元/人•年7%
三等奖400元/人•年15%
(2) 一、二、三等奖学金
以班级为单位,根据综合测评名次排列,列前35%名次者可参评奖学金。一、二、三等奖学金不全部评选的班级,可按学生数的3%、7%、15%的比例,只评选其中的一个等级。
1.4综合成绩计算标准
奖励分值计算办法,起始分值为0分。
(1)奖学金计分:
获得单项奖学金+1,三等奖学金+2,二等奖学金+3,一等奖学金+4,特等奖学金+5,校长奖学金+6。
(2)荣誉积分:
校级各种优秀个人+3,省级各种个人优秀+6,国家级各种优秀+12;
(3)学科竞赛:
省级以上学科竞赛成功参赛奖+1,省级三等奖+4、省二等奖+5、生一等奖+6,国家级三等奖+6、国家级二等奖+9、国家级一等奖+12,校级三等奖+1.校级二等奖+2,校级一等奖+3分。
(4)惩罚分值计算办法,起始分值为0分。
学院通报批评-1,校级警告-2,严重警告-3,记过-4,记大过-5,开除学籍留校察看-6。
4.1 账号、密码
账号:Headmaster
密码:123456
4.2 输入测试数据
(1)学生基本信息
存于“student.txt”文件。
(2)课程信息
存于“subject.txt”文件。
(3)课程成绩信息
C语言程序设计:存于“C语言程序设计.txt”文件。
高等数学1:存于“高等数学_1.txt”文件。
大学英语1:存于“大学英语_1.txt”文件。
计算机导论:存于“计算机导论_1.txt”文件。
大学英语2:存于“大学英语_2.txt”文件。
离散数学:存于“离散数学_2.txt”文件。
(4)学生品行成绩信息
存于“stCondSc.txt”文件。
(5)学生综合信息
存于“cominfo.txt”文件。
【运行前需要自行新建所需文件,必要时自己加上测试数据】
#include
#include
#include
#include
#include
using namespace std;
//学生基本信息
struct student
{
int stage; //年龄
char stnum[12]; //学号
char stname[20]; //姓名
char stsex[6]; //性别
char dornum[10]; //宿舍号
struct student *next;
};
//课程信息
struct subject
{
char subNum[20]; //课程编号
char subName[30]; //课程名
char cate[20]; //课程类别(选修、必修)
int term; //课程所在学期
float credit; //学分
struct subject *next;
};
//学生成绩信息
struct stscore
{
char stnum[12]; //学号
char subNum[20]; //课程编号
int mark; //课程成绩
char repair[4]; //是否重修
int cnt = 0; //不及格门次
struct stscore *next;
};
//学生品行分信息
struct stCondSc
{
char stnum[12]; //学号
int coumark; //品行成绩——辅导员
int headmark; //品行成绩——班主任
int classsmark; //品行成绩——班级
int conductmark; //品行分总分
struct stCondSc *next;
};
//学生综合信息
struct cominfo
{
char stnum[12]; //学号
char stname[20]; //姓名
char awdlev[10]; //获奖类别
int ayear, amon, aday; //获奖时间
int amark; //奖励分值
char puncate[10]; //惩处类别
int pyear, pmon, pday; //惩处时间
int pmark; //惩罚分值
int getcredit; //所获学分
struct cominfo *next;
};
struct student *st;//学生基本信息
struct subject *sub;//课程信息
struct stscore *stsc;//学生成绩信息
struct cominfo *coin;//学生综合信息
struct stCondSc *stcosc; //学生品行成绩信息
/* ***** 模块函数 ********* */
void creat(); //信息录入
void modify(); //信息修改
void ddelete(); //信息删除
void countStatics(); //统计分析
void ssort(); //信息排序
/* ****** 信息录入、修改、删除 ********* */
struct student* creatStudent(); //录入学生基本信息
struct subject* creatSubject(); //录入课程信息
struct stscore* creatSubScore(); //录入课程成绩
struct cominfo* creatAwdPunScore(); //录入综合信息
struct stCondSc* creatConductScore(); //录入学生品行成绩信息
struct student* insertStudent(struct student *st); //添加学生基本信息
struct subject* insertSubject(struct subject *head); //添加课程基本信息
struct student * modifyStudent(); //修改学生基本信息
struct subject * modifySubject(); //修改课程信息
struct stscore * modifySubScore(); //修改课程成绩信息
struct cominfo * modifyAwdPunScore(); //修改奖惩信息
struct stCondSc * modifyConductScore(); //修改品行成绩信息
void deleteStudent(); //删除学生基本信息
void deleteSubject(); //删除课程信息
void deleteStScore(); //删除课程成绩信息
void deleteStCondSc(); //删除品行成绩信息
void deleteCominfo(); //删除综合信息
/* ******* 输出查看 *************** */
void output(); //输出信息
void outputStudent(); //输出学生基本信息
void outputSubject(); //输出课程信息
void outputStScore(); //输出课程成绩
void outputStCondSc(); //输出学生品行分
void outputCominfo(); //输出学生综合信息
/* ***** 统计分析 ********* */
void countSubScore(); //某门课程按分数段成绩统计
void countAveScore(); //业务课程平均分按分数段统计
void countStScore(); //统计任意一名同学每门功课的班级排名以及业务课成绩总体排名
void countDorRank(); //以宿舍为单位进行成绩统计分析
void countFail(); //分学期统计挂科
void countChange(); //以业务课班级排名为依据分学期对比分
void schoshipAsse(); //奖学金评定
/* ****** 排序 ********* */
void subStScoreSort(); //按课程成绩(高->低)对学生排序
void failStcntSort(); //按挂科门次(高->低)对学生排序
void failSubSort(); //按不及格学生数对课程进行由高到低排序
void dorScoreSort(); //以宿舍为单位按成绩由高到低进行排序
void awdStSort(); //根据奖励对学生进行由高到低排序
void punStScore(); //根据惩罚情况对学生由低到高排序
void fprintfStudent(struct student *head);//将学生信息写入文件
struct student* loadStudent();//从文件中读取学生信息
void fprintfsubject(struct subject *head);//将课程信息写入文件
struct subject* loadSubject();//从文件中读取课程信息
//主函数
int main()
{
int choice, n, y = 1;
char admname[20]="1", password[16]="1"; //用户名,密码
char an[20], pw[16];
char c;
int i;
while (y)
{
system("cls");
printf("\n\n\n\n\n\n\n");
printf(" ╔*☆***◎***◇***☆*** 欢迎光临 ***☆***◇***◎***☆*╗\n");
printf(" *********************** 班主任管家系统 ************************\n\n");
printf("\n\n");
printf(" ============1-用户登录===========\n");
printf(" ============0-退出系统===========\n");
printf(" 请输入您的选择:");
scanf("%d", &n);
printf("\n");
getchar();
switch (n)
{
case 0: y = 0; break;
case 1:{
printf(" 请输入您的用户名:");
scanf("%s", an);
printf("\n");
printf(" 请输入您的密码:");
i = 0;
do
{
c = getch();
if (c == '\b')
{
printf("\b");
putchar('\0');
i--;
printf("\b");
}
else if (c != '\r')
{
printf("*");
pw[i] = c;
i++;
}
}while (c != '\r');
pw[i] = '\0';
printf("\n\n");
if (!(strcmp(admname,an)==0 && strcmp(password,pw)==0))
{
printf(" 验证失败,请重新输入!\n");
getchar();
getchar();
}
else
{
printf(" 验证通过!请按Enter键进入!\n");
getchar();
getchar();
int x = 1;
while (x)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" ------------------\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf(" || 1-信息录入 2-信息修改 ||\n\n");
printf(" || 3-信息查看 4-信息排序 ||\n\n");
printf(" || 5-统计分析 6-奖学金评定||\n\n");
printf(" || 7-信息删除 0-退出系统 ||\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: x = 0; break;
case 1: creat(); break;
case 2: modify(); break;
case 3: output(); break;
case 4: ssort(); break;
case 5: countStatics(); break;
case 6: schoshipAsse(); getchar(); getchar(); break;
case 7: ddelete(); break;
default :
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch
}//while(x)
}//else
}//case 1
break;
default :
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(n)
}//while(y)
return 0;
}//main
//信息录入
void creat()
{
st = (struct student *)malloc(sizeof(struct student));
sub = (struct subject *)malloc(sizeof(struct subject));
stsc = (struct stscore *)malloc(sizeof(struct stscore));
coin = (struct cominfo *)malloc(sizeof(struct cominfo));
stcosc = (struct stCondSc *)malloc(sizeof(struct stCondSc));
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *信息录入*\n");
printf(" ------------------\n\n");
printf(" ***********************************************\n\n");
printf(" ***********************************************\n\n");
printf(" || 1-学生基本信息录入 2-课程信息录入 ||\n\n");
printf(" || 3-课程成绩录入 4-综合信息录入 ||\n\n");
printf(" || 5-品行成绩录入 6-添加学生基本信息||\n\n");
printf(" || 7-添加课程信息 0-退出系统 ||\n\n");
printf(" ***********************************************\n\n");
printf(" ***********************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: st = creatStudent(); getchar(); break;
case 2: sub = creatSubject(); getchar(); break;
case 3: stsc = creatSubScore(); getchar(); break;
case 4: coin = creatAwdPunScore(); getchar(); break;
case 5: stcosc = creatConductScore(); getchar(); break;
case 6:
st = loadStudent();
st = insertStudent(st);
getchar();
break;
case 7:
sub = loadSubject();
sub = insertSubject(sub);
getchar();
break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
getchar();
}//while(y)
}//creat
//信息修改
void modify()
{
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *信息修改*\n");
printf(" ------------------\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf(" || 1-学生基本信息修改 2-课程信息修改 ||\n\n");
printf(" || 3-课程成绩修改 4-品行成绩修改 ||\n\n");
printf(" || 5-奖惩信息修改 0-退出系统 ||\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: st = modifyStudent(); getchar(); break;
case 2: sub = modifySubject(); getchar(); break;
case 3: stsc = modifySubScore(); getchar(); break;
case 4: stcosc = modifyConductScore(); getchar(); break;
case 5: coin = modifyAwdPunScore(); getchar(); break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
getchar();
}//while(y)
}//modify
//信息输出
void output()
{
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *信息查看*\n");
printf(" ------------------\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf(" || 1-查看学生基本信息 2-查看课程信息 ||\n\n");
printf(" || 3-查看学生品行成绩 4-查看课程成绩 ||\n\n");
printf(" || 5-查看学生综合信息 0-退出系统 ||\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: outputStudent(); getchar(); break;
case 2: outputSubject(); getchar(); break;
case 3: outputStCondSc(); getchar(); break;
case 4: outputStScore(); getchar(); break;
case 5: outputCominfo(); getchar(); break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
getchar();
}//while(y))
}//output
//统计分析
void countStatics()
{
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *统计分析*\n");
printf(" ------------------\n\n");
printf(" ****************************************************\n\n");
printf(" ****************************************************\n\n");
printf(" || 1-课程分数段统计 2-课程平均分分数段统计 ||\n\n");
printf(" || 3-学生个人排名统计 4-宿舍成绩统计分析 ||\n\n");
printf(" || 5-分学期挂科统计 6-学生进退分析 ||\n\n");
printf(" || 0-退出系统 ||\n\n");
printf(" ****************************************************\n\n");
printf(" ****************************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: countSubScore(); getchar(); break;
case 2: countAveScore(); getchar(); break;
case 3: countStScore(); getchar(); break;
case 4: countDorRank(); getchar(); break;
case 5: countFail(); getchar(); break;
case 6: countChange(); getchar(); break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
getchar();
}//while(y)
}
//信息排序
void ssort()
{
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *信息排序*\n");
printf(" ------------------\n\n");
printf(" **************************************************\n\n");
printf(" **************************************************\n\n");
printf(" || 1-学生课程成绩排序 2-学生挂科门次排序 ||\n\n");
printf(" || 3-课程挂科人次排序 4-宿舍成绩排序 ||\n\n");
printf(" || 5-学生奖励情况排序 6-学生惩处情况排序 ||\n\n");
printf(" || 0-退出系统 ||\n\n");
printf(" **************************************************\n\n");
printf(" **************************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
getchar();
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: subStScoreSort(); getchar(); break;
case 2: failStcntSort(); getchar(); break;
case 3: failSubSort(); getchar(); break;
case 4: dorScoreSort(); getchar(); break;
case 5: awdStSort(); getchar(); break;
case 6: punStScore(); getchar(); break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
}//while(y)
}//ssort
//信息删除
void ddelete()
{
int choice, y = 1;
while (y)
{
system("cls");
printf(" ------------------\n");
printf(" *班主任管家系统*\n");
printf(" *信息删除*\n");
printf(" ------------------\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf(" || 1-学生基本信息删除 2-课程信息删除 ||\n\n");
printf(" || 3-课程成绩删除 4-品行成绩删除 ||\n\n");
printf(" || 5-综合信息删除 0-退出系统 ||\n\n");
printf(" **********************************************\n\n");
printf(" **********************************************\n\n");
printf("请输入所选择的序号:");
scanf("%d",&choice);
system("cls");
switch (choice)
{
case 0: y = 0; break;
case 1: deleteStudent(); getchar(); break;
case 2: deleteSubject(); getchar(); break;
case 3: deleteStScore(); getchar(); break;
case 4: deleteStCondSc(); getchar(); break;
case 5: deleteCominfo(); getchar(); break;
default:
printf(" 输入错误,请重新输入!\n");
getchar();
break;
}//switch(choice)
getchar();
}//while(y)
}//modify
//判断学号是否已存在
//存在返回1,不存在返回0
int isNumExist(struct student *head, char *num)
{
struct student *q = head;
while (q != NULL)
{
if (strcmp(q ->stnum, num) == 0)
return 1;
q = q ->next;
}
return 0;
}
//将学生信息写入文件
void fprintfStudent(struct student *head)
{
FILE *fp;
struct student *p;
if ((fp = fopen("student.txt", "w")) == NULL)
{
printf("Can't open the file!\n");
return ;
}
p = head;
while (p != NULL)
{
fprintf(fp, "%s\t%s\t%s\t%d\t%s\n", p ->stnum, p ->stname, p ->stsex, p ->stage, p ->dornum);
p = p ->next;
}
fclose(fp);
}//fprintfStudent
//从文件中读取学生信息
struct student* loadStudent()
{
FILE *fp;
struct student *head, *tail, *p;
head = tail = NULL;
if ((fp = fopen("student.txt", "r")) == NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while (!feof(fp))
{
p = (struct student *)malloc(sizeof(struct student));
fscanf(fp, "%s\t%s\t%s\t%d\t%s\n", p ->stnum, p ->stname, p ->stsex, &p ->stage, p ->dornum);
if (head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}
tail ->next = NULL;
fclose(fp);
return head;
}//loadStudent
//录入学生基本信息
struct student* creatStudent()
{
struct student *head, *tail, *p;
head = (struct student *)malloc(sizeof(struct student));
int age, key, y = 1;
char num[12], sex[6], dn[10], name[20];
char kk[3] = "0";
char ss1[5] = "男", ss2[5] = "女";
head = tail = NULL;
printf("请输入学生信息,以学号0为结束!\n");
while (y)
{
printf("\n");
do
{
printf("请输入学生学号:");
scanf("%s", num);
if (strlen(num) != 10 && strcmp(kk, num) != 0)
{
printf("学号格式输入错误,请重新输入!\n");
key = 1;
}
else
{
key = isNumExist(head, num);
if (key == 1)
printf("该学号已存在,请重新输入!\n");
if (strcmp(kk, num) == 0)
y = 0;
}
}while (key == 1);
if (y != 0)
{
printf("请输入学生姓名:");
scanf("%s", name);
do
{
key = 1;
printf("请输入学生性别:");
scanf("%s", sex);
if (strcmp(sex, ss1)==0 || strcmp(sex, ss2)==0)
key = 0;
else
printf("性别输入错误,请重新输入!\n");
}while(key == 1);
printf("请输入学生年龄:");
scanf("%d", &age);
//getchar();
printf("请输入学生宿舍号:");
scanf("%s", dn);
printf("是否要存储该学生信息?\n");
printf(" 1-确定 0-取消\n");
int k;
scanf("%d", &k);
if (k == 1)
{
p = (struct student *)malloc(sizeof(struct student));
strcpy(p ->stname, name);
strcpy(p ->stnum, num);
strcpy(p ->stsex, sex);
strcpy(p ->dornum, dn);
p ->stage = age;
p ->next = NULL;
if(head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//if
}//if
}//while(y)
printf("是否要覆盖原有信息,并将其存入文件?");
printf(" 1-确认 0-取消\n");
printf("请选择:");
scanf("%d", &y);
if (y)
{
fprintfStudent(head);
printf("\n录入学生基本信息成功!\n");
}
printf("\n **按Enter返回!");
return head;
}//creatStudent
//添加学生基本信息
struct student* insertStudent(struct student *head)
{
struct student *tail, *p;
int age, key, y = 1;
char num[12], sex[6], dn[6], name[20];
char kk[3] = "0";
tail = head;
while (tail!=NULL && tail ->next!=NULL)
{
tail = tail ->next;
}
printf("请输入学生信息,以学号0为结束!\n");
while (y)
{
printf("\n");
do
{
printf("请输入学生学号:");
scanf("%s", num);
if (strlen(num) != 10 && strcmp(kk, num) != 0)
{
printf("学号格式输入错误,请重新输入!\n");
key = 1;
}
else
{
key = isNumExist(head, num);
if (key == 1)
printf("该学号已存在,请重新输入!\n");
if (strcmp(kk, num) == 0)
y = 0;
}
}while (key == 1);
if (y != 0)
{
printf("请输入学生姓名:");
scanf("%s", name);
printf("请输入学生性别:");
scanf("%s", sex);
printf("请输入学生年龄:");
scanf("%d", &age);
printf("请输入学生宿舍号:");
scanf("%s", dn);
printf("是否要存储该学生信息?\n");
printf(" 1-确定 0-取消\n");
int k;
scanf("%d", &k);
if (k == 1)
{
p = (struct student *)malloc(sizeof(struct student));
strcpy(p ->stname, name);
strcpy(p ->stnum, num);
strcpy(p ->stsex, sex);
strcpy(p ->dornum, dn);
p ->stage = age;
p ->next = NULL;
if(head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//if
}//if
}//while(y)
fprintfStudent(head);
printf("添加学生基本信息成功!\n");
printf("\n **按Enter返回!");
return head;
}//insertStudent
//判断学号是否已存在
//存在返回1,不存在返回0
int isNumExist(struct subject *head, char *num)
{
struct subject *q = head;
while (q != NULL)
{
if (strcmp(q ->subNum, num) == 0)
return 1;
q = q ->next;
}
return 0;
}//isNumExist
//将课程信息写入文件
void fprintfsubject(struct subject *head)
{
FILE *fp;
struct subject *p;
if ((fp = fopen("subject.txt", "w")) == NULL)
{
printf("Can't open the file!\n");
return ;
}
p = head;
while (p != NULL)
{
fprintf(fp, "%s\t%s\t%s\t%g\t%d\n", p ->subNum, p ->subName, p ->cate, p ->credit, p ->term);
p = p ->next;
}
fclose(fp);
}//fprintfsubject
//从文件中读取课程信息
struct subject* loadSubject()
{
FILE *fp;
struct subject *head, *tail, *p;
head = tail = NULL;
if ((fp = fopen("subject.txt", "r")) == NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while (!feof(fp))
{
p = (struct subject *)malloc(sizeof(struct subject));
fscanf(fp, "%s\t%s\t%s\t%g\t%d\n", p ->subNum, p ->subName, p ->cate, &p ->credit, &p ->term);
if (head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}
tail ->next = NULL;
fclose(fp);
return head;
}//loadSubject
//录入课程信息
struct subject* creatSubject()
{
struct subject *head, *tail, *p;
head = (struct subject *)malloc(sizeof(struct subject));
int key, y = 1;
char num[12], cate[6], name[20];
int term;
float credit;
char kk[3] = "0";
head = tail = NULL;
printf("请输入课程信息,以编号0为结束!\n");
while (y)
{
printf("\n");
do
{
printf("请输入课程编号:");
scanf("%s", num);
key = isNumExist(head, num);
if (key == 1)
printf("该编号已存在,请重新输入!\n");
if (strcmp(kk, num) == 0)
y = 0;
}while (key == 1);
if (y != 0)
{
printf("请输入课程名称:");
scanf("%s", name);
printf("请输入课程类别:");
scanf("%s", cate);
printf("请输入课程学分:");
scanf("%f", &credit);
printf("请输入课程所在学期:");
scanf("%d", &term);
printf("是否要存储该课程信息?\n");
printf(" 1-确定 0-取消\n");
int k;
scanf("%d", &k);
if (k == 1)
{
p = (struct subject *)malloc(sizeof(struct subject));
strcpy(p ->subName , name);
strcpy(p ->subNum, num);
strcpy(p ->cate, cate);
p ->term = term;
p ->credit = credit;
p ->next = NULL;
if(head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//if
}//if
}//while(y)
printf("是否要覆盖原有信息,并将其存入文件?");
printf(" 1-确认 0-取消\n");
printf("请选择:");
scanf("%d", &y);
if (y)
{
fprintfsubject(head);
printf("\n录入课程信息成功!\n");
}
printf("\n **按Enter返回!");
return head;
}//creatsubject
//添加课程信息
struct subject* insertSubject(struct subject *head)
{
struct subject *tail, *p;
int key, y = 1;
char num[12], cate[6], name[20];
int term;
float credit;
char kk[3] = "0";
tail = head;
while (tail!=NULL && tail ->next!=NULL)
{
tail = tail ->next;
}
printf("请输入课程信息,以编号0为结束!\n");
while (y)
{
printf("\n");
do
{
printf("请输入课程编号:");
scanf("%s", num);
key = isNumExist(head, num);
if (key == 1)
printf("该编号已存在,请重新输入!\n");
if (strcmp(kk, num) == 0)
y = 0;
}while (key == 1);
if (y != 0)
{
printf("请输入课程名称:");
scanf("%s", name);
printf("请输入课程类别:");
scanf("%s", cate);
printf("请输入课程学分:");
scanf("%f", &credit);
printf("请输入课程所在学期:");
scanf("%d", &term);
printf("是否要存储该课程信息?\n");
printf(" 1-确定 0-取消\n");
int k;
scanf("%d", &k);
if (k == 1)
{
p = (struct subject *)malloc(sizeof(struct subject));
strcpy(p ->subName , name);
strcpy(p ->subNum, num);
strcpy(p ->cate, cate);
p ->term = term;
p ->credit = credit;
p ->next = NULL;
if(head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//if
}//if
}//while(y)
fprintfsubject(head);
printf("添加课程信息成功!\n");
printf("\n **按Enter返回!");
return head;
}//insertStudent
//判断学号与成绩是否已存在
//存在返回1,不存在返回0
int isNumExist(struct stscore *a, char *stnum, int n)
{
for (int i = 0; i < n; i++)
{
if (strcmp(a[i].stnum, stnum)==0)
return 1;
}
return 0;
}//isNumExist
//将课程成绩写入文件
void fprintfstscore(struct stscore *head, char *subname)
{
FILE *fp;
struct stscore *p;
if ((fp = fopen(subname, "w")) == NULL)
{
printf("Can't open the file!\n");
return ;
}
p = head;
while (p != NULL)
{
fprintf(fp, "%s\t%s\t%d\t%s\n", p ->stnum, p ->subNum, p ->mark, p ->repair);
p = p ->next;
}
fclose(fp);
}//fprintfstscore
//录入课程成绩
struct stscore * creatSubScore()
{
struct subject *head_sub, *r, *a[20];
struct stscore *head_sc, *p, *tail;
struct student *head_st, *q;
char term[3];
char subname[20];
int cnt;
int mark, k, t;
head_sc = (struct stscore *)malloc(sizeof(struct stscore));
head_st = loadStudent();
r = head_sub = loadSubject();
tail = head_sc;
printf("请输入学期:");
scanf("%s", term);
t = 0 + term[0] - '0';
printf(" 第%d学期课程\n", t);
printf(" =========================\n");
cnt = 1;
while (r)
{
if (r ->term == t)
{
a[cnt] = r;
printf(" %d -- %s\n", cnt++, r ->subName);
}
r = r ->next;
}
printf(" 请选择:");
scanf("%d", &t);
strcpy(subname, a[t] ->subName);
strcat(subname, "_");
strcat(subname, term);
strcat(subname, ".txt");
system("cls");
printf(" %s 课程成绩录入\n", a[t] ->subName);
printf(" =======================\n");
printf("请输入对应学号的成绩\n");
printf(" 学 号 成绩\n");
q = head_st;
while (q)
{
p = (struct stscore *)malloc(sizeof(struct stscore));
tail ->next = p;
tail = p;
printf(" %s : ", q ->stnum);
strcpy(p ->stnum ,q ->stnum);
strcpy(p ->subNum, a[t] ->subNum);
do
{
k = 1;
scanf("%d", &mark);
if (mark < 0 || mark > 100)
{
printf("成绩输入错误,请重新输入:");
k = 0;
}
}while (k == 0);
p ->mark = mark;
if (p ->mark < 60)
strcpy(p ->repair, "Y");
else
strcpy(p ->repair, "N");
q = q ->next;
}//while
tail ->next = NULL;
fprintfstscore(head_sc ->next, subname);
printf("\n录入课程成绩成功!\n");
printf("\n **按Enter返回!");
return head_sc;
}//creatSubScore
//判断学号是否已存在
//存在返回1,不存在返回0
int isNumExist(struct stCondSc *head, char *stNum)
{
struct stCondSc *q = head;
while (q != NULL)
{
if (strcmp(q ->stnum, stNum) == 0)
return 1;
q = q ->next;
}
return 0;
}//isNumExist
//将学生品行成绩信息写入文件
void fprintfstCondSc(struct stCondSc *head)
{
FILE *fp;
struct stCondSc *p;
if ((fp = fopen("stCondSc.txt", "w")) == NULL)
{
printf("Can't open the file!\n");
return ;
}
p = head;
while (p != NULL)
{
fprintf(fp, "%s\t%d\t%d\t%d\t%d\n", p ->stnum, p ->coumark, p ->headmark, p ->classsmark, p ->conductmark);
p = p ->next;
}
fclose(fp);
}//fprintfstCondSc
//录入学生品行成绩信息
struct stCondSc* creatConductScore()
{
struct stCondSc *head, *tail, *p;
struct student *head_st, *q;
int mark, k;
head = (struct stCondSc*)malloc(sizeof(struct stCondSc));
q = head_st = loadStudent();
tail = head;
printf("请输入学生品行成绩信息\n");
while (q)
{
p = (struct stCondSc *)malloc(sizeof(struct stCondSc));
tail ->next = p;
tail = p;
printf("学号:%s\n", q ->stnum);
strcpy(p ->stnum ,q ->stnum);
printf("辅导员打分:");
do
{
k = 1;
scanf("%d", &mark);
if (mark < 0 || mark > 100)
{
printf("成绩输入错误,请重新输入:");
k = 0;
}
}while (k == 0);
p ->coumark = mark;
printf("班主任打分:");
do
{
k = 1;
scanf("%d", &mark);
if (mark < -1 || mark > 100)
{
printf("成绩输入错误,请重新输入:");
k = 0;
}
}while (k == 0);
p ->headmark = mark;
printf("班级打分:");
do
{
k = 1;
scanf("%d", &mark);
if (mark < 0 || mark > 100)
{
printf("成绩输入错误,请重新输入:");
k = 0;
}
}while (k == 0);
p ->classsmark = mark;
p ->conductmark = p ->classsmark + p ->coumark + p ->headmark;
printf("\n");
q = q ->next;
}//while
fprintfstCondSc(head ->next);
printf("\n录入品行成绩成功!\n");
printf("\n **按Enter返回!");
return head;
}//creatConductScore
//判断学号是否已存在
//存在返回1,不存在返回0
int isNumExist(struct cominfo *head, char *stNum)
{
struct cominfo *q = head;
while (q != NULL)
{
if (strcmp(q ->stnum, stNum) == 0)
return 1;
q = q ->next;
}
return 0;
}//isNumExist
//将学生综合信息写入文件
void fprintfStCominfo(struct cominfo *head)
{
FILE *fp;
struct cominfo *p;
if ((fp = fopen("cominfo.txt", "w")) == NULL)
{
printf("Can't open the file!\n");
return ;
}
p = head;
while (p != NULL)
{
fprintf(fp, "%s\t%s\t%d\n", p ->stnum, p ->stname, p ->getcredit);
fprintf(fp, "%s\t%d-%d-%d\t%d\n", p ->awdlev, p ->ayear, p ->amon, p ->aday, p ->amark);
fprintf(fp, "%s\t%d-%d-%d\t%d\n", p ->puncate, p ->pyear, p ->pmon, p ->pday, p ->pmark);
p = p ->next;
}
fclose(fp);
} //fprintfAwdPunScore
//录入学生综合信息
struct cominfo* creatAwdPunScore()
{
struct cominfo *head, *tail, *p;
struct student *head_st, *q;
int t;
head = (struct cominfo *)malloc(sizeof(struct cominfo));
tail = head;
q = head_st = loadStudent();
printf("请输入学生综合信息\n");
while (q)
{
p = (struct cominfo *)malloc(sizeof(struct cominfo));
tail ->next = p;
tail = p;
printf("学号:%s\n", q ->stnum);
printf("姓名:%s\n", q ->stname);
strcpy(p ->stnum, q ->stnum);
strcpy(p ->stname, q ->stname);
printf("是否有奖励记录:");
printf("1 - 是 0 - 否\n");
scanf("%d", &t);
if (t)
{
printf("请输入奖励类别:");
scanf("%s", p ->awdlev);
printf("请输入获奖时间(年 月 日):");
scanf("%d %d %d", &p ->ayear, &p ->amon, &p ->aday);
printf("请输入奖励分值:");
scanf("%d", &p ->amark);
}
else
{
strcpy(p ->awdlev, "无");
p ->aday = 0;
p ->amon = 0;
p ->aday = 0;
p ->amark = 0;
}
printf("是否有惩处记录:");
printf("1 - 是 0 - 否\n");
scanf("%d", &t);
if(t)
{
printf("请输入惩处类别:");
scanf("%s", p ->puncate);
printf("请输入惩处时间:");
scanf("%d %d %d", &p ->pyear, &p ->amon, &p ->pday);
printf("请输入惩罚分值:");
scanf("%d", &p ->pmark);
}
else
{
strcpy(p ->puncate, "无");
p ->pyear = 0;
p ->pmon = 0;
p ->pday = 0;
p ->pmark = 0;
}
printf("\n");
q = q ->next;
}//while
fprintfStCominfo(head ->next);
printf("录入学生综合信息成功!\n");
printf("\n **按Enter返回!");
return head;
}//creatAwdPunScore
//修改学生基本信息
struct student* modifyStudent()
{
char stnum[15];
char sex[6];
struct student* head, *p;
int key = 1, t;
char ss1[5] = "男", ss2[5] = "女";
printf("请输入要修改学生的学号:");
do
{
scanf("%s", stnum);
if (strlen(stnum) != 10)
{
printf("学号格式输入错误,请重新输入!\n");
printf("请输入学号:");
}
else
key = 0;
}while (key == 1);
head = loadStudent();
p = head;
while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
{
p = p ->next;
}
if (p == NULL)
printf("未找到,修改失败!\n");
else
{
printf("请输入修改后的信息:\n");
printf("请输入姓名:");
scanf("%s", p ->stname);
do
{
key = 1;
printf("请输入性别:");
scanf("%s", sex);
if (strcmp(sex, ss1)==0 || strcmp(sex, ss2)==0)
key = 0;
else
printf("性别输入错误,请重新输入!\n");
}while(key == 1);
strcpy(p ->stsex, sex);
printf("请输入年龄:");
scanf("%d", &p ->stage);
printf("请输入宿舍号:");
scanf("%s", p ->dornum);
printf(" *确认修改?\n");
printf(" 1-确认 0-取消\n ");
scanf("%d", &t);
if (t)
{
fprintfStudent(head);
printf("修改成功!\n");
}
}//else
printf("\n **按Enter返回!");
return head;
}//modifyStudent
//修改课程信息
struct subject * modifySubject()
{
struct subject *head, *p;
char subnum[20];
printf("请输入要修改课程的课程号:");
scanf("%s", subnum);
head = loadSubject();
p = head;
while (p!=NULL && strcmp(p ->subNum,subnum)!=0)
{
p = p ->next;
}
if (p != NULL)
{
printf("请输入修改后的课程信息:\n");
printf("请输入课程名称:");
scanf("%s", p ->subName);
printf("请输入课程类别:");
scanf("%s", p ->cate);
printf("请输入课程学分:");
scanf("%f", &p ->credit);
printf("请输入课程所在学期:");
scanf("%d", &p ->term);
fprintfsubject(head);
printf("修改成功!\n");
}//if
else
printf("未找到,修改失败!\n");
printf("\n **按Enter返回!");
return head;
}//modifySubject
//从文件中读取课程成绩
struct stscore * loadStscore(char *modname)
{
FILE *fp;
struct stscore *head, *tail, *p;
head = tail = NULL;
if ((fp = fopen(modname, "r")) == NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while (!feof(fp))
{
p = (struct stscore *)malloc(sizeof(struct subject));
fscanf(fp, "%s\t%s\t%d\t%s\n", p ->stnum, p ->subNum, &p ->mark, p ->repair);
if (head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//while
tail ->next = NULL;
fclose(fp);
return head;
}//loadSubject
//判断学号是否存在
int isNumExist(struct stscore *head, char *num)
{
struct stscore *q = head;
while (q != NULL)
{
if (strcmp(q ->stnum , num) == 0)
return 1;
q = q ->next;
}
return 0;
}//isNumExist
//修改课程成绩信息
struct stscore * modifySubScore()
{
struct stscore *head, *p;
struct subject *head_sub, *r, *a[10];
char subname[20], stnum[15];
int mark;
int t, cnt;
char term[3];
printf("请输入学期:");
scanf("%s", term);
t = 0 + term[0] - '0';
r = head_sub = loadSubject();
printf(" 第%d学期课程\n", t);
printf(" =========================\n");
cnt = 1;
while (r)
{
if (r ->term == t)
{
a[cnt] = r;
printf(" %d -- %s\n", cnt++, r ->subName);
}
r = r ->next;
}
printf(" 请选择:");
scanf("%d", &t);
strcpy(subname, a[t] ->subName);
strcat(subname, "_");
strcat(subname, term);
strcat(subname, ".txt");
system("cls");
printf("请输入学号:");
scanf("%s", stnum);
head = loadStscore(subname);
p = head;
while (p!=NULL && strcmp(p ->stnum, stnum) != 0)
{
p = p ->next;
}
if (p != NULL)
{
printf("请输入修改后的信息:\n");
printf("请输入成绩:");
scanf("%d", &mark);
while (mark>100 || mark < 0)
{
printf("成绩格式错误,请重新输入!\n");
printf("请输入成绩:");
scanf("%d", &mark);
}
p ->mark = mark;
if (p ->mark >= 60)
strcpy(p ->repair, "N");
else
strcpy(p ->repair, "Y");
fprintfstscore(head, subname);
printf("\n **修改成功!\n");
}//if
else
printf(" **未找到,修改失败!\n");
printf("\n **按Enter返回!");
return head;
}//modifySubScore
//从文件中读入学生品行信息
struct stCondSc * loadstCondSc()
{
FILE *fp;
struct stCondSc *head, *tail, *p;
head = tail = NULL;
if ((fp = fopen("stCondSc.txt", "r")) == NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while (!feof(fp))
{
p = (struct stCondSc *)malloc(sizeof(struct stCondSc));
fscanf(fp, "%s\t%d\t%d\t%d\t%d\n", p ->stnum, &p ->coumark, &p ->headmark, &p ->classsmark, &p ->conductmark);
if (head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}
tail ->next = NULL;
fclose(fp);
return head;
}//loadstCondSc
//修改品行成绩信息
struct stCondSc * modifyConductScore()
{
char stnum[12];
struct stCondSc *head, *p;
int key;
printf("请输入要修改学生的学号:");
do
{
scanf("%s", stnum);
if (strlen(stnum) != 10)
{
printf("学号格式输入错误,请重新输入!\n");
printf("请输入学号:");
key = 1;
}
else
key = 0;
}while (key == 1);
p = head = loadstCondSc();
while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
{
p = p ->next;
}
if (p == NULL)
printf("未找到,修改失败!\n");
else
{
printf("请输入修改后的信息:\n");
printf("辅导员打分:");
scanf("%d", &p ->coumark);
printf("班主任打分:");
scanf("%d", &p ->headmark);
printf("班级打分:");
scanf("%d", &p ->classsmark);
p ->conductmark = p ->classsmark + p ->coumark + p ->headmark;
fprintfstCondSc(head);
printf(" 修改成功!\n");
}//else
printf("\n **按Enter返回!\n");
return head;
}//modifyConductScore
//从文件中读入学生品行信息
struct cominfo * loadstCominfo()
{
FILE *fp;
struct cominfo *head, *tail, *p;
head = tail = NULL;
if ((fp = fopen("cominfo.txt", "r")) == NULL)
{
printf("Can't open the file!\n");
exit(0);
}
while (!feof(fp))
{
p = (struct cominfo *)malloc(sizeof(struct cominfo));
fscanf(fp, "%s\t%s\t%d\n", p ->stnum, p ->stname, &p ->getcredit);
fscanf(fp, "%s\t%d-%d-%d\t%d\n", p ->awdlev, &p ->ayear, &p ->amon, &p ->aday, &p ->amark);
fscanf(fp, "%s\t%d-%d-%d\t%d\n", p ->puncate, &p ->pyear, &p ->pmon, &p ->pday, &p ->pmark);
if (head == NULL)
head = p;
else
tail ->next = p;
tail = p;
}//while
tail ->next = NULL;
fclose(fp);
return head;
}//loadstCominfo
//修改奖惩信息
struct cominfo * modifyAwdPunScore()
{
char stnum[12];
struct cominfo *head, *p;
int key;
printf("请输入要修改学生的学号:");
do
{
scanf("%s", stnum);
if (strlen(stnum) != 10)
{
printf("学号格式输入错误,请重新输入!\n");
printf("请输入学号:");
key = 1;
}
else
key = 0;
}while (key == 1);
p = head = loadstCominfo();
while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
{
p = p ->next;
}
if (p == NULL)
printf("未找到,修改失败!\n");
else
{
printf("请输入修改后的信息:\n");
printf("是否有奖励记录:");
printf("1 - 是 0 - 否\n");
int t;
scanf("%d", &t);
if (t)
{
printf("请输入奖励类别:");
scanf("%s", p ->awdlev);
printf("请输入获奖时间(年 月 日):");
scanf("%d %d %d", &p ->ayear, &p ->amon, &p ->aday);
printf("请输入奖励分值:");
scanf("%d", &p ->amark);
}//if
else
{
strcpy(p ->awdlev, "无");
p ->ayear = 0;
p ->amon = 0;
p ->aday = 0;
p ->amark = 0;
}//else
printf("是否有惩处记录:");
printf("1 - 是 0 - 否\n");
scanf("%d", &t);
if(t)
{
printf("请输入惩处类别:");
scanf("%s", p ->puncate);
printf("请输入惩处时间:");
scanf("%d %d %d", &p ->pyear, &p ->pmon, &p ->pday);
printf("请输入惩罚分值:");
scanf("%d", &p ->pmark);
}//if
else
{
strcpy(p ->puncate, "无");
p ->pyear = 0;
p ->pmon = 0;
p ->pday = 0;
p ->pmark = 0;
}//else
p ->getcredit = p ->amark - p ->pmark;
fprintfStCominfo(head);
printf("\n **修改成功,按Enter返回!\n");
}//else
return head;
}//modifyAwdPunScore
//输出学生基本信息
void outputStudent()
{
struct student *head, *p;
p = head = loadStudent();
printf("\n\n\t\t \t\t*****学生基本信息*****\n");
printf("\t\t ==============================================\n");
printf("\t\t 学 号\t 姓 名\t性别\t年龄\t宿舍号\n");
printf("\t\t ==============================================\n");
while (p)
{
printf("\t\t %s\t%s\t %s\t %d\t%s\n", p ->stnum, p ->stname, p ->stsex, p ->stage, p ->dornum);
p = p ->next;
}
printf("\t\t ==============================================\n");
printf("\n **按Enter返回!");
}//outputStudent
//输出课程信息
void outputSubject()
{
struct subject *head, *p;
p = head = loadSubject();
printf("\n\n\t\t\t *******课 程 信 息*******\n");
printf("\t\t ============================================\n");
printf("\t\t 课程号 课程名\t类别\t学分\t学期\n");
printf("\t\t ============================================\n");
while (p)
{
printf("\t\t %s\t %s\t%s\t%g\t%d\n", p ->subNum, p ->subName, p ->cate, p ->credit, p ->term);
p = p ->next;
}
printf("\t\t ============================================\n");
printf("\n **按Enter返回!");
}//outputSubject
//输出课程成绩
void outputStScore()
{
struct stscore *head_sc, *p;
struct student *head_st, *q;
struct subject *head_sub, *r;
int term;
char t[3];
char subname[10][20], sn[10][20];
int cnt, k;
printf("请输入学期:");
scanf("%d", &term);
t[0] = '0' + term - 0;
t[1] = '\0';
//查找该学期的所有课程
r = head_sub = loadSubject();
head_st = loadStudent();
cnt = 1;
while (r)
{
if (r ->term == term)
{
strcpy(sn[cnt], r ->subName);
strcat(sn[cnt], "_");
strcat(sn[cnt], t);
strcat(sn[cnt], ".txt");
strcpy(subname[cnt++], r ->subName);
}
r = r ->next;
}
//输出该学期课程选择
system("cls");
printf("\n\t\t\t\t ***课程成绩查询***\n");
printf(" \t\t\t =========================\n");
for (int i = 1; i < cnt; i++)
{
printf("\t\t\t\t%d ---- %s\n\n", i, subname[i]);
}
printf(" \t\t\t =========================\n");
printf("\t\t\t 请选择:");
scanf("%d", &k);
//输出课程成绩
system("cls");
p = head_sc = loadStscore(sn[k]);
printf("\n\n\t\t *******课 程 成 绩 信 息*******\n");
printf("\t\t ==============================================\n");
printf("\t\t **课程编号:%s\n", head_sc ->subNum);
printf("\t\t **课程名:%s\n", subname[k]);
printf("\t\t ==============================================\n");
printf("\t\t 学 号 \t姓名\t 成绩\t 是否重修\n");
printf("\t\t ==============================================\n");
while (p)
{
printf("\t\t %s\t", p ->stnum);
q = head_st;
while (q)
{
if (strcmp(q->stnum, p ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t %s\n", p ->mark, p ->repair);
p = p ->next;
}//while
printf("\t\t ==============================================\n");
printf("\n **按Enter返回!");
}//outputStScore
//输出学生品行分
void outputStCondSc()
{
struct stCondSc *head, *p;
struct student *head_st, *q;
p = head = loadstCondSc();
q = head_st = loadStudent();
printf("\n\n\t \t\t*******品 行 成 绩 信 息*******\n");
printf("\t ================================================================\n");
printf("\t 学 号 \t姓 名\t 辅导员评分\t班主任评分\t班级评分\n");
printf("\t ================================================================\n");
while (p)
{
printf("\t %s\t", p ->stnum);
q = head_st;
while (q)
{
if (strcmp(q->stnum, p ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t\t %d\t\t %d\n", p ->coumark, p ->headmark, p ->classsmark);
p = p ->next;
}
printf("\t ================================================================\n");
printf("\n **按Enter返回!");
}//outputStCondSc
//输出学生综合信息
void outputCominfo()
{
struct cominfo *head, *p;
p = head = loadstCominfo();
printf(" \t\t*******学 生 综 合 信 息*******\n");
printf(" =========================================================\n");
printf(" 学 号 \t姓名\t 综合分\n");
printf(" \t\t获奖类别 奖励分值 获奖日期\n");
printf(" \t\t惩处类别 惩罚分值 惩处日期\n");
printf(" ---------------------------------------------------------\n");
while (p)
{
printf(" %s\t%s\t %d\n", p ->stnum, p ->stname, p ->getcredit);
printf(" %s\t %d\t %d-%d-%d\n", p ->awdlev, p ->amark, p ->ayear, p ->amon, p ->aday);
printf(" %s\t %d\t %d-%d-%d\n", p ->puncate, p ->pmark, p ->pyear, p ->pmon, p ->pday);
printf(" ---------------------------------------------------------\n");
p = p ->next;
}
printf("\n **按Enter返回!");
}//outputCominfo
/* ***** 统计分析 ********* */
//某门课程按分数段成绩统计
void countSubScore()
{
struct stscore *head_sc, *p;
struct student *head_st, *q;
struct subject *head_sub, *r;
// 总 90+ 75+ 60+
int cnt = 0, cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0;
struct stscore *c1[20], *c2[20], *c3[20], *c4[20];
float per;
int term, key;
char t[3];
char subname[10][20], sn[10][20];
int cntt, k;
printf("请输入学期:");
scanf("%d", &term);
t[0] = '0' + term - 0;
t[1] = '\0';
//查找该学期的所有课程
r = head_sub = loadSubject();
//head_st = loadStudent();
cntt = 1;
while (r)
{
if (r ->term == term)
{
strcpy(sn[cntt], r ->subName);
strcat(sn[cntt], "_");
strcat(sn[cntt], t);
strcat(sn[cntt], ".txt");
strcpy(subname[cntt++], r ->subName);
}
r = r ->next;
}
//输出该学期课程选择
system("cls");
printf("\n\t\t\t\t ***课程成绩查询***\n");
printf(" \t\t\t =========================\n");
for (int i = 1; i < cntt; i++)
{
printf("\t\t\t\t%d ---- %s\n\n", i, subname[i]);
}
printf(" \t\t\t =========================\n");
printf("\t\t\t 请选择:");
scanf("%d", &k);
p = head_sc = loadStscore(sn[k]);
while (p)
{
if (p ->mark >= 90)
c1[cn1++] = p;
else if (p ->mark >= 75)
c2[cn2++] = p;
else if (p ->mark >= 60)
c3[cn3++] = p;
else
c4[cn4++] = p;
cnt++;
p = p ->next;
}//while
per = (cn1+cn2+cn3) / float(cnt);
system("cls");
printf("\n\n\t\t **课程信息统计分析***\n\n");
printf("\t\t 课程名称:%s\n", subname[k]);
printf("\t\t 及格率: %g%%\n", 100*per);
printf("\t\t ==========================\n");
printf("\t\t 分数段 人数\n");
printf("\t\t 90~100: %d\n", cn1);
printf("\t\t 75~89: %d\n", cn2);
printf("\t\t 60~74: %d\n", cn3);
printf("\t\t 0~59: %d\n", cn4);
printf("\t\t ==========================\n");
printf("\n\t\t是否要输出各分数段学生?\n");
printf("\t\t 1 - 是 0 - 否\n");
printf("\t\t 请选择:");
scanf("%d", &key);
if (key)
{
system("cls");
head_st = loadStudent();
printf("\n\t\t **各分数段学生**\n");
printf("\t\t===============================================\n");
printf("\t\t 学 号 \t姓名\t 成绩\t 是否重修\n");
printf("\t\t===============================================\n");
printf("\t 90~100: \n");
for (int i = 0; i < cn1; i++)
{
printf("\t %s\t", c1[i] ->stnum);
q = head_st;
while (q)
{
if (strcmp(q ->stnum, c1[i] ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t", c1[i] ->mark);
printf(" %s\n", c1[i] ->repair);
}//for
printf("\t 75~89: \n");
for (int i = 0; i < cn2; i++)
{
printf("\t %s\t", c2[i] ->stnum);
q = head_st;
while (q)
{
if (strcmp(q ->stnum, c2[i] ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t", c2[i] ->mark);
printf(" %s\n", c2[i] ->repair);
}//for
printf("\t 60~74: \n");
for (int i = 0; i < cn3; i++)
{
printf("\t %s\t", c3[i] ->stnum);
q = head_st;
while (q)
{
if (strcmp(q ->stnum, c3[i] ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t", c3[i] ->mark);
printf(" %s\n", c3[i] ->repair);
}//for
printf("\t 0~59: \n");
for (int i = 0; i < cn4; i++)
{
printf("\t %s\t", c4[i] ->stnum);
q = head_st;
while (q)
{
if (strcmp(q ->stnum, c4[i] ->stnum) == 0)
{
printf("%s", q ->stname);
break;
}
q = q ->next;
}
printf(" %d\t", c4[i] ->mark);
printf(" %s\n", c4[i] ->repair);
}//for
}//if
printf("\t\t===============================================\n");
printf("\n\n统计分析完毕,按Enter返回!\n");
}//countSubScore
//业务课程平均分按分数段统计
void countAveScore()
{
struct stscore *head_sc, *p;
struct stscore *head_sc2, *q;
struct subject *head_sub, *r;
char subname[20][20], t[3];
// 总 90+ 75+ 60+
int cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0;
int term, cnt;
printf("请输入学期:");
scanf("%d", &term);
t[0] = '0' + term - 0;
t[1] = '\0';
r = head_sub = loadSubject();
cnt = 0;
while (r)
{
if (r ->term == term)
{
strcpy(subname[cnt], r ->subName);
strcat(subname[cnt], "_");
strcat(subname[cnt], t);
strcat(subname[cnt], ".txt");
cnt++;
}
r = r ->next;
}//while
head_sc2 = loadStscore(subname[0]);
for (int i = 1; i < cnt; i++)
{
p = head_sc = loadStscore(subname[i]);
while (p)
{
q = head_sc2;
while (q && strcmp(p ->stnum, q ->stnum)!=0)
{
q = q ->next;
}
if (q)
q ->mark += p ->mark;
p = p ->next;
}
}//for
float sum;
p = head_sc2;
cnt--;
while (p)
{
sum = p ->mark / cnt;
if (sum >= 90)
cn1++;
else if (sum >= 75)
cn2++;
else if (sum >= 60)
cn3++;
else
cn4++;
p = p ->next;
}//while
printf("\n\n\t\t\t **各分数段人数**\n");
printf("\t\t\t =====================\n");
printf("\t\t\t 分数段 人数\n");
printf("\t\t\t =====================\n");
printf("\t\t\t 90~100: %d\n", cn1);
printf("\t\t\t 75~89: %d\n", cn2);
printf("\t\t\t 60~74: %d\n", cn3);
printf("\t\t\t 0~59: %d\n", cn4);
printf("\t\t\t =====================\n");
printf("\n\n **统计分析完毕,按Enter返回!\n");
}//countAveScore
//根据学号从小到大对成绩进行排序
struct stscore * sortGrade(struct stscore *head)
{
struct stscore *head_new, *p, *r, *s, *t;
head_new = (struct stscore *)malloc(sizeof(struct stscore));
p = head;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && strcmp(p ->stnum, r ->stnum)>0)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
return head_new ->next;
}//sortGrade
//统计任意一名同学每门功课的班级排名以及业务课成绩总体排名
void countStScore()
{
struct stscore *head_sc, *p, *q;
struct student *stu, *r;
struct subject *head_sub, *f;
int t, cnt, k;
char term[3];
char subname[10][20], sn[10][20];
printf("请输入学期:");
scanf("%d", &t);
term[0] = '0' + t - 0;
term[1] = '\0';
//择取相应学期课程
cnt = 1;
f = head_sub = loadSubject();
while (f)
{
if (f ->term == t)
{
strcpy(subname[cnt], f ->subName);
strcpy(sn[cnt], subname[cnt]);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
cnt++;
}
f = f ->next;
}
//输出课程
system("cls");
printf("\n\t\t\t\t ***成绩排名统计***\n");
printf(" \t\t\t =========================\n");
for (int i = 1; i < cnt; i++)
{
printf("\t\t\t\t%d ---- %s\n\n", i, sn[i]);
}
printf(" \t\t\t =========================\n");
printf("\t\t\t 请选择:");
scanf("%d", &k);
//统计排名
p = head_sc = loadStscore(subname[k]);
while (p)
{
p ->cnt = 1;
q = head_sc;
while (q)
{
if (q ->mark > p ->mark)
{
p ->cnt++;
}
q = q ->next;
}
p = p ->next;
}//while
system("cls");
printf("\n\n ***学生业务课程成绩***\n");
printf(" 排名统计\n");
printf("\n 课程名:%s\n", sn[k]);
printf(" \t ==========================================\n");
printf(" \t\t 学 号 姓 名\t 排名\n");
printf(" \t ==========================================\n");
p = head_sc;
stu = loadStudent();
while (p)
{
printf("\t\t%s", p ->stnum);
r = stu;
while (r)
{
if (strcmp(r ->stnum, p ->stnum) == 0)
{
printf(" %s", r ->stname);
break;
}
r = r ->next;
}
printf("\t %d\n", p ->cnt);
p = p ->next;
}//while
printf(" \t ==========================================\n");
printf("\n**统计完毕,按Enter返回!");
}//countStScore
//以宿舍为单位进行成绩统计分析
void countDorRank()
{
struct student *head_st, *p;
struct subject *head_sub, *q;
struct stscore *head_sc[10], *f;
char dor_num[10];
char subname[10][20], sn[10][20];
int t, cnt;
char term[3];
printf("请输入学期:");
scanf("%d", &t);
term[0] = '0' + t - 0;
term[1] = '\0';
q = head_sub = loadSubject();
cnt = 1;
while (q)
{
if (q ->term == t)
{
strcpy(sn[cnt], q ->subName);
strcpy(subname[cnt], sn[cnt]);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
cnt++;
}
q = q ->next;
}//while
p = head_st = loadStudent();
for (int i = 1; i < cnt; i++)
head_sc[i] = loadStscore(subname[i]);
printf("请输入宿舍号:");
scanf("%s", dor_num);
system("cls");
printf("\n *宿舍成员成绩统计分析*\n");
printf("\n 宿舍号:%s\n", dor_num);
printf(" ========================================================================\n");
printf(" 学 号\t 姓 名\t ");
for (int i = 1; i < cnt; i++)
printf("%s ", sn[i]);
printf("\n");
printf(" ========================================================================\n");
while (p)
{
if (strcmp(p ->dornum, dor_num) == 0)
{
printf(" %s", p ->stnum);
printf(" %s", p ->stname);
for (int i = 1; i < cnt; i++)
{
f = head_sc[i];
while (f && strcmp(p ->stnum, f->stnum)!=0)
f = f ->next;
if (f)
printf("%11d", f ->mark);
else
printf(" 无");
}
printf("\n");
}//if
p = p ->next;
}//while
printf(" ========================================================================\n");
printf("\n**统计完毕,按Enter返回!");
}//countDorRank
//分学期统计挂科
void countFail()
{
struct student *head_st, *q;
struct subject *head_sub, *r;
struct stscore *head_sc[10], *p;
int t, cnt, tt;
char term[3];
char subname[10][20];
printf("请输入学期:");
scanf("%d", &tt);
term[0] = '0' + tt - 0;
term[1] = '\0';
r = head_sub = loadSubject();
cnt = 1;
//选课程
while (r)
{
if (r ->term == tt)
{
strcpy(subname[cnt], r ->subName);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
head_sc[cnt] = loadStscore(subname[cnt]);
cnt++;
}
r = r ->next;
}//while
q = head_st = loadStudent();
while (q)
{
q ->stage = 0;
for (int i = 1; i < cnt; i++)
{
p = head_sc[i];
while (p && strcmp(p ->stnum, q ->stnum)!=0)
p = p ->next;
if (p)
{
if (p ->mark < 60)
q ->stage++;
}
}//for
q = q ->next;
}//while
system("cls");
printf("\t\t **分学期统计挂科次数**\n");
printf("\n\t\t **学期:%d\n", tt);
printf("\t\t =========================================\n");
q = head_st;
t = 1;
printf("\t\t 序号 学 号\t\t 姓 名\t 挂科次数\n");
printf("\t\t =========================================\n");
while (q)
{
printf("\t\t%5d %s %s %d\n", t++, q ->stnum, q ->stname, q ->stage);
q = q ->next;
}
printf("\t\t =========================================\n");
printf("\n **统计输出完成,按Enter返回!");
}//countFail
//以业务课班级排名为依据分学期对比分
void countChange()
{
int cnt = 1;
struct stscore *head_sc1[10], *head_sc2[10], *p, *q;
struct student *head_st, *r;
struct subject *head_sub, *f;
char subname_1[10][20];
char subname_2[10][20];
int t1, t2, n1, n2;
char term1[3], term2[3];
printf("请输入学期一:");
scanf("%d", &t1);
term1[0] = '0' + t1 - 0;
term1[1] = '\0';
printf("请输入学期二:");
scanf("%d", &t2);
term2[0] = '0' + t2 - 0;
term2[1] = '\0';
n1 = 1;
f = head_sub = loadSubject();
while (f)
{
if (f ->term == t1)
{
strcpy(subname_1[n1], f ->subName);
strcat(subname_1[n1], "_");
strcat(subname_1[n1], term1);
strcat(subname_1[n1], ".txt");
head_sc1[n1] = loadStscore(subname_1[n1]);
n1++;
}
f = f ->next;
}//while
n2 = 1;
f = head_sub;
while (f)
{
if (f ->term == t2)
{
strcpy(subname_2[n2], f ->subName);
strcat(subname_2[n2], "_");
strcat(subname_2[n2], term2);
strcat(subname_2[n2], ".txt");
head_sc2[n2] = loadStscore(subname_2[n2]);
n2++;
}
f = f ->next;
}//while
//算成绩
for (int i = 2; i < n1; i++)
{
p = head_sc1[1];
while (p)
{
q = head_sc1[i];
while (q)
{
if (strcmp(p ->stnum, q ->stnum) == 0)
{
p ->mark += q ->mark;
break;
}
q = q ->next;
}//while
p = p ->next;
}//while
}//for
for (int i = 2; i < n2; i++)
{
p = head_sc2[1];
while (p)
{
q = head_sc2[i];
while (q)
{
if (strcmp(p ->stnum, q ->stnum) == 0)
{
p ->mark += q ->mark;
break;
}
q = q ->next;
}//while
p = p ->next;
}//while
}//for
//统计名次
p = head_sc1[1];
while (p)
{
p ->cnt = 1;
q = head_sc1[1];
while (q)
{
if (q ->mark > p ->mark)
p ->cnt++;
q = q ->next;
}
p = p ->next;
}
p = head_sc2[1];
while (p)
{
p ->cnt = 1;
q = head_sc2[1];
while (q)
{
if (q ->mark > p ->mark)
p ->cnt++;
q = q ->next;
}
p = p ->next;
}
system("cls");
head_st = loadStudent();
printf("\n\n\t **学生成绩排名统计**\n");
printf("\t ===========================================================\n");
printf("\t 序号 学 号\t\t 姓 名\t 第%d学期 第%d学期 排名变动\n", t1, t2);
printf("\t ===========================================================\n");
p = head_sc1[1];
while (p)
{
printf("\t%5d %s", cnt++, p ->stnum);
r = head_st;
while (r && strcmp(r ->stnum, p ->stnum)!=0)
{
r = r ->next;
}
if (r)
printf(" %s", r ->stname);
printf("%7d", p ->cnt);
q = head_sc2[1];
while (q)
{
if (strcmp(p ->stnum, q ->stnum) == 0)
{
printf("%9d", q ->cnt);
printf("%9d\n", p ->cnt - q ->cnt);
}
q = q ->next;
}
p = p ->next;
}//while
printf("\t ===========================================================\n");
printf("\n **统计输出完成,按Enter返回!");
}//countChange
//按课程成绩(高->低)对学生排序
void subStScoreSort()
{
struct stscore *head_new, *r, *s;
struct stscore *head, *p, *t;
struct subject *head_sub, *q;
char subname[10][20], sn[10][20];
int k, tt, cnt, key;
char term[3];
head_new = (struct stscore *)malloc(sizeof(struct stscore));
printf("请输入课程学期:");
scanf("%d", &tt);
term[0] = '0' + tt - 0;
term[1] = '\0';
cnt = 1;
q = head_sub = loadSubject();
while (q)
{
if (q ->term == tt)
{
strcpy(subname[cnt], q ->subName);
strcpy(sn[cnt], subname[cnt]);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
cnt++;
}
q = q ->next;
}
printf("\t\t\t**第%d学期课程**\n", tt);
printf("\t\t==================================\n");
for (int i = 1; i < cnt; i++)
printf("\t\t %d -- %s\n\n", i, sn[i]);
printf("\t\t==================================\n");
printf("\t\t 请选择:");
scanf("%d", &key);
p = head = loadStscore(subname[key]);
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->mark < r ->mark)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
printf("\n\t\t是否输出排序后成绩信息?\n");
printf("\t\t 1 - 是 0 - 否\n");
printf("\n\t\t请选择:");
scanf("%d", &k);
if (1 == k)
{
system("cls");
printf("\n\n\t\t **课程成绩排序**\n\n");
printf("\n\t\t 课程名:%s\n", sn[key]);
printf("\t\t =========================================\n");
r = head_new ->next;
int num = 1;
printf("\t\t 名次 学 号\t成绩 是否重修\n");
printf("\t\t =========================================\n");
while (r)
{
printf("\t\t %d\t%s\t%d\t %s\n", num++, r ->stnum, r ->mark, r ->repair);
r = r ->next;
}
printf("\t\t =========================================\n");
}//if
printf("\n **按Enter返回!");
getchar();
}//subStScoreSort
//按挂科门次(高->低)对学生排序
void failStcntSort()
{
struct stscore *head_new, *r, *s, *t;
struct subject *head_sub, *f;
struct stscore *head_sc1, *head_sc, *p, *q;
struct student *head_st, *u;
char subname[10][20];
int tt, cnt;
char term[3];
head_new = (struct stscore *)malloc(sizeof(struct stscore));
printf("请输入学期:");
scanf("%d", &tt);
term[0] = '0' + tt - 0;
term[1] = '\0';
f = head_sub = loadSubject();
cnt = 1;
while (f)
{
if (f ->term == tt)
{
strcpy(subname[cnt], f ->subName);
strcpy(subname[cnt], f ->subName);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
cnt++;
}
f = f ->next;
}//while
p = head_sc1 = loadStscore(subname[1]);
while (p)
{
p ->cnt = 0;
if (p ->mark < 60)
p ->cnt++;
p = p ->next;
}
for (int i = 2; i < cnt; i++)
{
p = head_sc1;
head_sc = loadStscore(subname[i]);
while (p)
{
q = head_sc;
while (q)
{
if (strcmp(p ->stnum, q ->stnum) == 0)
{
if (q ->mark < 60)
{
p ->cnt++;
break;
}
}
q = q ->next;
}//while
p = p ->next;
}//while
}//for
//排序
p = head_sc1;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->cnt < r ->cnt)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
//输出
system("cls");
head_st = loadStudent();
printf("\n\n\t\t\t **挂科信息统计排序**\n");
printf("\t\t============================================\n");
r = head_new ->next;
int num = 1;
printf("\t\t 名次 学 号\t姓 名 挂科次数\n");
printf("\t\t============================================\n");
while (r)
{
printf("\t\t %d\t%s\t", num++, r ->stnum);
u = head_st;
while (u)
{
if (strcmp(u ->stnum, r ->stnum) == 0)
printf("%s", u ->stname);
u = u ->next;
}
printf(" %d\n", r ->cnt);
r = r ->next;
}
printf("\t\t============================================\n");
getchar();
printf("\n **排序输出完毕,按Enter返回!\n");
}//failStcntSort
struct
{
int a, b;
float per;
char subname[20];
char subnum[10];
}ssub[10];
//按不及格学生数对课程进行由高到低排序
void failSubSort()
{
struct stscore *head_sc, *p;
struct subject *head_sub, *f;
char subname[10][20], sn[10][20];
int t, cnt;
char term[3];
printf("请输入学期:");
scanf("%d", &t);
term[0] = '0' + t - 0;
term[1] = '\0';
f = head_sub = loadSubject();
cnt = 1;
while (f)
{
if (f ->term == t)
{
strcpy(subname[cnt], f ->subName);
strcpy(sn[cnt], f ->subName);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
cnt++;
}
f = f ->next;
}//while
for (int i = 1; i < cnt; i++)
{
ssub[i].b = 0;
ssub[i].a = 0;
p = head_sc = loadStscore(subname[i]);
strcpy(ssub[i].subname, sn[i]);
strcpy(ssub[i].subnum, p ->subNum);
while (p)
{
ssub[i].a++;
if (p ->mark < 60)
ssub[i].b++;
p = p ->next;
}
ssub[i].per =100 * (float)ssub[i].b / float(ssub[i].a);
}//for
for (int i = 1; i < cnt-1; i++)
{
for (int j = i+1; j < cnt; j++)
{
if (ssub[i].b < ssub[j].b)
{
ssub[3] = ssub[i];
ssub[i] = ssub[j];
ssub[j] = ssub[3];
}
}
}//for
system("cls");
printf("\n\n\t\t\t **第%d学期课程挂科率**\n", t);
printf("\t\t\t 统计排名\n");
printf("\t\t =================================================\n");
printf("\t\t 课程编号 课程名称\t 挂科人数 挂科率\n");
printf("\t\t =================================================\n");
for (int i = 1; i < cnt; i++)
{
printf("\t\t%7s%19s%10d%10g%%\n", ssub[i].subnum, ssub[i].subname, ssub[i].b, ssub[i].per);
}
printf("\t\t =================================================\n");
printf("\n **排序输出完毕,按Enter返回!\n");
getchar();
}//failSubSort
//根据成绩从高到低学生进行排序
struct student * sortGrade(struct student *head)
{
struct student *head_new, *p, *r, *s, *t;
head_new = (struct student *)malloc(sizeof(struct student));
p = head;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->stage < r ->stage )
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
return head_new ->next;
}//sortGrade
//以宿舍为单位按成绩由高到低进行排序
void dorScoreSort()
{
struct student *head_st, *p;
struct student *head_st_dor, *r;
struct stscore *head_sub[10], *q;
struct subject *head, *f;
int t, m, tt, cnt;
float cont = 0;
char term[3];
char subname[10][20];
char dor[10];
printf("请输入学期:");
scanf("%d", &tt);
term[0] = '0' + tt - 0;
term[1] = '\0';
printf("请输入宿舍号:");
scanf("%s", dor);
cnt = 1;
f = head = loadSubject();
while (f)
{
if (f ->term == tt)
{
strcpy(subname[cnt], f ->subName);
strcat(subname[cnt], "_");
strcat(subname[cnt], term);
strcat(subname[cnt], ".txt");
head_sub[cnt] = loadStscore(subname[cnt]);
cnt++;
}
f = f ->next;
}//while
r = head_st_dor = (struct student *)malloc(sizeof(struct student));
p = head_st = loadStudent();
while (p)
{
if (strcmp(p ->dornum, dor) == 0)
{
r ->next = p;
r = p;
}
p = p ->next;
}//while
r ->next = NULL;
r = head_st_dor ->next;
t = 0;
while (r)
{
r ->stage = 0;
for (int i = 1; i < cnt; i++)
{
q = head_sub[i];
while (q)
{
if (strcmp(q ->stnum, r ->stnum) == 0)
r ->stage+= q ->mark;
q = q ->next;
}
}//for
t++;
r ->stage /= (cnt-1);
cont += r ->stage;
r = r ->next;
}//while
cont /= t;
system("cls");
printf("\n\t\t **宿舍成绩排名**\n");
printf("\n\t\t **宿舍号:%s\n", dor);
printf("\t\t **宿舍平均成绩:%g\n", cont);
printf("\t\t ====================================\n");
printf("\t\t 序号 学 号\t 姓 名\t 成绩\n");
printf("\t\t ====================================\n");
r = head_st_dor ->next = sortGrade(head_st_dor ->next);
m = 1;
while (r)
{
printf("\t\t%5d %s %s%6d\n", m++, r ->stnum, r ->stname, r ->stage);
r = r ->next;
}
printf("\t\t ====================================\n");
printf("\n\n **排序输出完毕,按Enter返回!");
getchar();
}//dorScoreSort
//根据成绩从高到低学生进行排序
struct cominfo * sortGradeA(struct cominfo *head)
{
struct cominfo *head_new, *p, *r, *s, *t;
head_new = (struct cominfo *)malloc(sizeof(struct cominfo));
p = head;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->amark < r ->amark)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
return head_new ->next;
}//sortGrade
//根据奖励对学生进行由高到低排序
void awdStSort()
{
struct cominfo *head, *p;
int cnt = 1;
head = loadstCominfo();
p = head =sortGradeA(head);
printf("\n\t\t **学生奖励信息排名**\n");
printf("\t\t ====================================\n");
printf("\t\t 序号 学 号\t 姓 名\t 成绩\n");
printf("\t\t ====================================\n");
while (p)
{
printf("\t\t%5d %s %s%6d\n", cnt++, p ->stnum, p ->stname, p ->amark);
p = p ->next;
}
printf("\t\t ====================================\n");
printf("\n\n **排序输出完毕,按Enter返回!");
}//awdStSort
//根据成绩从高到低学生进行排序
struct cominfo * sortGradeP(struct cominfo *head)
{
struct cominfo *head_new, *p, *r, *s, *t;
head_new = (struct cominfo *)malloc(sizeof(struct cominfo));
p = head;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->pmark > r ->pmark)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}
return head_new ->next;
}//sortGrade
//根据惩罚情况对学生由低到高排序
void punStScore()
{
struct cominfo *head, *p;
int cnt = 1;
head = loadstCominfo();
p = head =sortGradeP(head);
printf("\n\t\t **学生惩处信息排名**\n");
printf("\t\t ====================================\n");
printf("\t\t 序号 学 号\t 姓 名\t 成绩\n");
printf("\t\t ====================================\n");
while (p)
{
printf("\t\t%5d %s %s%6d\n", cnt++, p ->stnum, p ->stname, p ->pmark);
p = p ->next;
}
printf("\t\t ====================================\n");
printf("\n\n **排序输出完毕,按Enter返回!");
}//punStScore
//根据品行分排序
struct stCondSc * SortStcondSc(struct stCondSc *head)
{
struct stCondSc *head_new, *p, *r, *s, *t;
head_new = (struct stCondSc *)malloc(sizeof(struct stCondSc));
p = head;
head_new ->next = p;
p = p ->next;
head_new ->next ->next = NULL;
while (p)
{
t = p ->next;
r = head_new ->next;
s = head_new;
while (r!=NULL && p ->conductmark < r ->conductmark)
{
s = r;
r = r ->next;
}
s ->next = p;
p ->next = r;
p = t;
}//while
return head_new ->next;
}//SortStcondSc
//奖学金评定
void schoshipAsse()
{
int tt;
char term[3];
int cnt, n, m;
struct subject *head, *f;//课程信息
struct cominfo *head_com, *q; //综合信息
struct stscore *head_sub[10], *p; //课程成绩
struct stCondSc *head_con, *r; //品行成绩
struct student *head_st, *t; //基本信息
char subname[10][20];
head = loadSubject();
head_st = loadStudent();
head_con = loadstCondSc();
head_con = SortStcondSc(head_con);
printf("请输入学期:");
scanf("%d", &tt);
term[0] = '0' + tt - 0;
term[1] = '\0';
f = head;
m = 0;
while (f)
{
if (f ->term == tt)
{
strcpy(subname[m], f ->subName);
strcat(subname[m], "_");
strcat(subname[m], term);
strcat(subname[m], ".txt");
head_sub[m] = loadStscore(subname[m]);
m++;
}
f = f ->next;
}//while
cnt = 0;
r = head_con;
while (r)
{
cnt++;
r ->conductmark = cnt;
r ->classsmark = 0;
r = r ->next;
}
//判断品行分(前70%)
n = cnt * 0.7;
r = head_con;
while (r)
{
if (r ->conductmark > n)
r ->classsmark++;
r = r ->next;
}
//判断挂科
r = head_con;
while (r)
{
if (r ->classsmark == 0)
{
for (int i = 1; i < m; i++)
{
if (r ->classsmark == 0)
{
int flag = 1;
p = head_sub[i];
while (p)
{
if (strcmp(r ->stnum, p ->stnum) == 0)
{
if (p ->mark < 60)
{
r ->classsmark++;
flag = 0;
break;
}
}
p = p ->next;
}//while
if (flag == 0)
break;
}//if
}//for
}//if
r = r ->next;
}//while
//判断惩处情况
head_com = loadstCominfo();
r = head_con;
while (r)
{
if (r ->classsmark == 0)
{
q = head_com;
while (q)
{
if (strcmp(q ->stnum, r ->stnum) == 0)
if (q ->pmark < 0)
r ->classsmark++;
q = q ->next;
}
}//if
r = r ->next;
}//while
struct stCondSc *head_new, *s;
head_new = (struct stCondSc *)malloc(sizeof(struct stCondSc));
s = head_new;
r = head_con;
while (r)
{
if (r ->classsmark == 0)
{
s ->next = r;
s = r;
}
r = r ->next;
s ->next = NULL;
}//while
cnt = 1;
s = head_new ->next = SortStcondSc(head_new ->next);
while (s)
{
if (cnt > 6)
break;
else if (cnt == 4)
printf("\n\t\t ** 三等奖 **\n");
else if (cnt == 2)
printf("\n\t\t ** 二等奖 **\n");
else if (cnt == 1)
printf("\n\n\t\t ** 一等奖 **\n");
cnt++;
printf("\t\t %s", s ->stnum);
t = head_st;
while (t)
{
if (strcmp(t ->stnum, s ->stnum) == 0)
printf("\t %s\n", t ->stname);
t = t ->next;
}
s = s ->next;
}//while
printf("\n\n **奖学金评定完成,按Enter返回!\n");
}//schoshipAsse
//删除学生基本信息
void deleteStudent()
{
char stnum[12];
struct student *head_st, *head, *p, *q;
head = (struct student *)malloc(sizeof(struct student));
head ->next = head_st = loadStudent();
printf("请输入要删除的学生的学号:");
scanf("%s", stnum);
p = head_st;
q = head;
while (p && strcmp(stnum, p ->stnum) != 0)
{
q = p;
p = p ->next;
}
if (p)
{
int key;
printf("\n 您要删除的学生信息\n");
printf(" 学号:%s\n", p ->stnum);
printf(" 姓名:%s\n", p ->stname);
printf("\n **确定删除?\n");
printf(" 1 - 确定 0 - 取消\n");
scanf("%d", &key);
if (key == 1)
{
q ->next = p ->next;
free(p);
printf("\n **删除成功!");
fprintfStudent(head ->next);
}
}//if
else
printf("\n **未找到,删除失败!");
printf("\n **按Enter返回!");
}//deleteStudent
//删除课程信息
void deleteSubject()
{
char subnum[12];
struct subject *head_sub, *head, *p, *q;
head = (struct subject *)malloc(sizeof(struct subject));
head ->next = head_sub = loadSubject();
printf("请输入要删除的课程的课程号:");
scanf("%s", subnum);
p = head_sub;
q = head;
while (p && strcmp(subnum, p ->subNum) != 0)
{
q = p;
p = p ->next;
}
if (p)
{
int key;
printf("\n 您要删除的课程信息\n");
printf(" 课程号:%s\n", p ->subNum);
printf(" 课程名:%s\n", p ->subName);
printf("\n **确定删除?\n");
printf(" 1 - 确定 0 - 取消\n");
scanf("%d", &key);
if (key == 1)
{
q ->next = p ->next;
free(p);
printf("\n **删除成功!");
fprintfsubject(head ->next);
}
}//if
else
printf("\n **未找到,删除失败!");
printf("\n **按Enter返回!");
}//deleteSubject
//删除课程成绩信息
void deleteStScore()
{
int t, cnt;
char term[3];
char stnum[12], subname[20];
struct subject *head_sub, *r, *a[10];
struct stscore *head_stsc, *head, *p, *q;
head = (struct stscore *)malloc(sizeof(struct stscore));
printf("请输入学期:");
scanf("%s", term);
t = 0 + term[0] - '0';
r = head_sub = loadSubject();
printf(" 第%d学期课程\n", t);
printf(" =========================\n");
cnt = 1;
while (r)
{
if (r ->term == t)
{
a[cnt] = r;
printf(" %d -- %s\n", cnt++, r ->subName);
}
r = r ->next;
}
printf(" 请选择:");
scanf("%d", &t);
strcpy(subname, a[t] ->subName);
strcat(subname, "_");
strcat(subname, term);
strcat(subname, ".txt");
printf("请输入要删除成绩的学生学号:");
scanf("%s", stnum);
head ->next = head_stsc = loadStscore(subname);
p = head_stsc;
q = head;
while (p && strcmp(stnum, p ->stnum) != 0)
{
q = p;
p = p ->next;
}
if (p)
{
int key;
printf("\n\n 您要删除的信息\n");
printf(" 课程名:%s\n", a[t] ->subName);
printf(" 学号:%s\n", stnum);
printf("\n **确定删除成绩信息?\n");
printf(" 1 - 确定 0 - 取消\n");
scanf("%d", &key);
if (key == 1)
{
q ->next = p ->next;
free(p);
printf("\n **删除成功!");
fprintfstscore(head ->next, subname);
}
}//if
else
printf("\n **未找到,删除失败!");
printf("\n **按Enter返回!");
}//deleteStScore
//删除品行成绩信息
void deleteStCondSc()
{
char stnum[12];
struct stCondSc *head_st, *head, *p, *q;
head = (struct stCondSc *)malloc(sizeof(struct stCondSc));
head ->next = head_st = loadstCondSc();
printf("请输入要删除的学生的学号:");
scanf("%s", stnum);
p = head_st;
q = head;
while (p && strcmp(stnum, p ->stnum) != 0)
{
q = p;
p = p ->next;
}
if (p)
{
int key;
printf("\n 您要删除的学生信息\n");
printf(" 学号:%s\n", p ->stnum);
printf("\n **确定删除?\n");
printf(" 1 - 确定 0 - 取消\n");
scanf("%d", &key);
if (key == 1)
{
q ->next = p ->next;
free(p);
printf("\n **删除成功!");
fprintfstCondSc(head ->next);
}
}//if
else
printf("\n **未找到,删除失败!");
printf("\n **按Enter返回!");
}//deleteStCondSc
//删除综合信息
void deleteCominfo()
{
char stnum[12];
struct cominfo *head_st, *head, *p, *q;
head = (struct cominfo *)malloc(sizeof(struct cominfo));
head ->next = head_st = loadstCominfo();
printf("请输入要删除的学生的学号:");
scanf("%s", stnum);
p = head_st;
q = head;
while (p && strcmp(stnum, p ->stnum) != 0)
{
q = p;
p = p ->next;
}
if (p)
{
int key;
printf("\n 您要删除的学生信息\n");
printf(" 学号:%s\n", p ->stnum);
printf(" 姓名:%s\n", p ->stname);
printf("\n **确定删除?\n");
printf(" 1 - 确定 0 - 取消\n");
scanf("%d", &key);
if (key == 1)
{
q ->next = p ->next;
free(p);
printf("\n **删除成功!");
fprintfStCominfo(head ->next);
}
}//if
else
printf("\n **未找到,删除失败!");
printf("\n **按Enter返回!");
}//deleteCominfo