#include <stdio.h>
#include <stdlib.h>
#include "file.h"
int main()
{
struct node* runMain(struct node *head,int choice);
void menu();
struct node *head=NULL;
int choice;
head=readFile(head);
if(!head){
creatFile();
head=readFile(head);
}//判断是否存在原始数据文件,如果没有就创建
do{
menu();//打印一级菜单
printf("输入所选功能的序号并按回车键\n");
scanf("%d",&choice);
if(choice>=0&&choice<=5)
head=runMain(head,choice);//执行所选项
else
printf("输入错误,请输入1-5\n");//判断是否输入错误
}while(choice);
saveFile(head);//关闭前保存文件
return 0;
}
void printHead()//打印第一行中文
{
printf("%8s%10s%8s%6s%6s%6s%6s%7s%7s","学号","姓名","性别","语文","数学","外语","政治","总分","名次\n");
}
void menu()//一级菜单
{
printf(" ********1.显示基本信息********\n");
printf(" ********2.基本信息管理********\n");
printf(" ********3.学生成绩管理********\n");
printf(" ********4.考试成绩统计********\n");
printf(" ********5.根据条件查询********\n");
printf(" ********0. 退出 ********\n");
}
void menuBase()//基本信息菜单
{
printf(" ********1.插入学生记录********\n");
printf(" ********2.删除学生记录********\n");
printf(" ********3.修改学生记录********\n");
printf(" ********0.返回上层菜单********\n");
}
void menuScore()//学生成绩菜单
{
printf(" ********1.计算学生总分********\n");
printf(" ********2.根据总分排名********\n");
printf(" ********0.返回上层菜单********\n");
}
void menuCount()//考试成绩菜单
{
printf(" ********1.求课程最高分********\n");
printf(" ********2.求课程最低分********\n");
printf(" ********3.求课程平均分********\n");
printf(" ********4.查不及格学生********\n");
printf(" ********0.返回上层菜单********\n");
}
void menuSearch()//查找菜单
{
printf(" ********1.按学号查询 ********\n");
printf(" ********0.返回上层菜单********\n");
}
struct node *baseManage(struct node *head)//基本信息菜单执行
{
int choice;
Type data;
struct node *p;
do
{
menuBase();
printf("选择一项序号输入并回车\n");
scanf("%d",&choice);
switch(choice)
{
case 1: readNode(&data);
head=InsertOrder(head,data,1);
break;
case 2: printf("输入要删除的学号:\n");
scanf("%d",&data.num);
head=Delete(head,data);
break;
case 3: readNode(&data);
p=SearchNode(head,data,1);
if(p) p->data=data;
else printf("该学生不存在\n");
break;
case 0: break;
}
}while(choice);
return head;
}
void rankCalculate(struct node *head)//按总分计算名次
{
struct node *head2=NULL,*p,*q;
int count=0,current=0;
for(p=head;p;p=p->next,count++)
head2=InsertOrder(head2,p->data,2);
for(p=head2;p;p=p->next)
{
current++;
q=SearchNode(head,p->data,1);
(q->data).rank=count-current+1;
}
}
struct node *scoreManage(struct node *head)//成绩管理菜单执行
{
int choice,i;
struct node *p;
do
{
menuScore();
printf("选择一项序号输入并回车\n");
scanf("%d",&choice);
switch(choice)
{
case 1:for(p=head;p;p=p->next)
{
(p->data).total=0;
for(i=0;i<4;i++)
(p->data).total+=(p->data).score[i];
}
break;
case 2:rankCalculate(head);
break;
case 0:break;
}
}while(choice);
return head;
}
void bjg(struct node *head)//实现查找不及格的模块
{
struct node *p;
int i,k=0,w=0;
for(p=head;p;p=p->next)
for(i=0;i<4;i++)
if((p->data).score[i]<60)
{
k++;
if(w=0) printf("不及格是:\n");
printHead();
if(k=1){
w+=1;
printNode(p->data);
}
printf("\n");
break;
}
}
void highMark(struct node *head,int *high)//实现查找最高分的模块
{
struct node *p;
int i;
for(p=head;p;p=p->next)
for(i=0;i<4;i++)
if((p->data).score[i]>high[i])
high[i]=(p->data).score[i];
printf("最高分是:\n");
printHead();
for(i=0;i<4;i++)
printf("%8d",high[i]);
printf("\n");
}
void lowMark(struct node *head,int *low)//最低分
{
struct node *p;
int i;
for(p=head;p;p=p->next)
for(i=0;i<4;i++)
if((p->data).score[i]<low[i])
low[i]=(p->data).score[i];
printf("最低分是:\n");
printHead();
for(i=0;i<4;i++)
printf("%8d",low[i]);
printf("\n");
}
void average(struct node *head,double *aver)//平均分
{
struct node *p;
int i,count=0;
for(p=head;p;p=p->next)
{
count++;
for(i=0;i<4;i++)
aver[i]+=(p->data).score[i];
}
for(i=0;i<4;i++)
printf("%8.2f",aver[i]);
printf("\n");
}
void countManage(struct node *head)//考试成绩菜单执行
{
int choice;
int high[4]={0,0,0,0},low[4]={100,100,100,100};
double aver[4]={0};
do
{
menuCount();
printf("选择一项序号输入并回车\n");
scanf("%d",&choice);
switch(choice)
{
case 1: highMark(head,high);
break;
case 2: lowMark(head,low);
break;
case 3: average(head,aver);
break;
case 4:bjg(head);
}
}while(choice);
}
struct node *searchManage(struct node *head)//查找菜单执行
{
int choice;
Type data;
struct node *p;
do
{
menuSearch();
printf("选择一项序号输入并回车\n");
scanf("%d",&choice);
switch(choice)
{
case 1:printf("输入学号:\n");
scanf("%ld",&data.num);
break;
case 0:break;
}
if(choice>=1&&choice<=1)
if(p=SearchNode(head,data,choice))
{
printHead();
printNode(p->data);
}
else
printf("该生不在列表内\n");
}while(choice);
return head;
}
struct node* runMain(struct node *head,int choice)//主菜单执行
{
switch(choice)
{
case 1:printHead();
head=printList(head);
break;
case 2:head=baseManage(head);
break;
case 3:head=scoreManage(head);
break;
case 4:countManage(head);
break;
case 5:head=searchManage(head);
break;
case 0:break;
}
return head;
}
C语言学生考试信息管理系统
4星 · 超过85%的资源 需积分: 31 33 浏览量
2012-06-19
21:29:44
上传
评论 2
收藏 5KB RAR 举报
yj84839350
- 粉丝: 1
- 资源: 1
最新资源
- ZArchiver.Pro_0.9.5.apk
- vmware环境配置.mp4
- 548springboot + vue 大学生社团活动平台.zip(可运行源码+数据库文件+文档)
- 微信小程序 辩论倒计时小程序源码 作业设计demo 计算机专业参考
- 深入探究文件IO,嵌入式Linux
- 微信备忘录小程序源码 作业设计demo 计算机专业作业
- 微信小程序 仿百度小说小程序 看小说小程序 实现源码
- 锂电资料包-锂离子电池技术干货资料合集.zip
- EMC EMI资料大全电磁兼容电磁干扰设计资料工程师必备经验资料35个合集.zip
- 547springboot + vue 交流互动系统.zip(可运行源码+数据库文件+文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈