#include<stdio.h>
#define SIZE 30
struct student
{
int num;//学号//
char name[20];//姓名//
char sex[3];//性别//
char clas[15];//班级//
double score[3];//成绩//
}student;
void menu();//主菜单//
void modimenu();//数据修改菜单//
void dealmenu();//数据处理菜单//
void statmenu();//统计菜单//
int input(struct student p[SIZE]);
void modi(struct student p[SIZE],int n);
void deal(struct student p[SIZE],int n);
void prin(struct student p[SIZE],int n);
void sort(struct student p[SIZE],int n);
void find(struct student p[SIZE],int n);
void stat(struct student p[SIZE],int n);
void num(struct student p[SIZE],int n);
void name(struct student p[SIZE],int n);
void average(struct student p[SIZE],int n);
void fail(struct student p[SIZE],int n);
int main()
{
int c;
int number=0; // number表示已经输入信息的学生的人数 //
struct student stu[SIZE];
do //反复调用主菜单,执行选择的操作,直到选择了退出系统才结束//
{
menu();
scanf("%d",&c);
switch(c)
{
case 1: number=input(stu); break;
case 2: modi(stu,number); break;
case 3: deal(stu,number); break;
case 4: prin(stu,number); break;
case 5: printf("\t\t谢谢使用!\n"); break;
default: printf("\t\t所选择的操作不存在!请重新选择!\n"); break;
}
}while(c!=5);
}
void menu() //系统主菜单//
{
printf("\n\t\t**************************************************\n");
printf("\t\t***Student Information Management System of ZQU***\n");
printf("\t\t*** ***\n");
printf("\t\t*** 1:输入数据 ***\n");
printf("\t\t*** 2:修改数据 ***\n");
printf("\t\t*** 3:处理数据 ***\n");
printf("\t\t*** 4:输出数据 ***\n");
printf("\t\t*** 5:退出系统 ***\n");
printf("\t\t*** ***\n");
printf("\t\t**************************************************\n");
printf("\t\t请选择需要进行的操作(1~5):");
}
void modimenu() //修改的项目菜单//
{
printf("\t*************************************************************\n");
printf("\t*** ***\n");
printf("\t*** 1:学号 ***\n");
printf("\t*** 2:姓名 ***\n");
printf("\t*** 3:性别 ***\n");
printf("\t*** 4:班级 ***\n");
printf("\t*** 5:语文成绩 ***\n");
printf("\t*** 6:数学成绩 ***\n");
printf("\t*** 7:英语成绩 ***\n");
printf("\t*** 8:退出修改 ***\n");
printf("\t*** ***\n");
printf("\t**************************************************************\n");
printf("\t\t请选择需要修改的项目(1~8):");
}
void dealmenu() //数据处理菜单//
{
printf("\n\t\t********************************************\n");
printf("\t\t*** ***\n");
printf("\t\t*** 1:按学号排序 ***\n");
printf("\t\t*** 2:查询 ***\n");
printf("\t\t*** 3:统计 ***\n");
printf("\t\t*** 4:返回主菜单 ***\n");
printf("\t\t*** ***\n");
printf("\t\t********************************************\n");
printf("\t\t请选择具体的处理内容(1~4):");
}
void statmenu() //统计菜单//
{
printf("\n\t\t********************************************\n");
printf("\t\t*** 1:统计平均分 ***\n");
printf("\t\t*** 2:统计2门以上课程不及格学生信息 ***\n");
printf("\t\t*** 3:返回上级菜单 ***\n");
printf("\t\t*** ***\n");
printf("\t\t********************************************\n");
printf("\t\t请再选择具体的统计内容(1~3):");
}
void findmenu()//查询菜单//
{
printf("\n\t\t********************************************\n");
printf("\t\t*** ***\n");
printf("\t\t*** 1:按学号查询 ***\n");
printf("\t\t*** 2:返回主菜单 ***\n");
printf("\t\t*** ***\n");
printf("\t\t********************************************\n");
printf("\t\t请选择查询方式(1~2):");
}
int input(struct student p[SIZE]) //输入数据函数,每输入一条记录,人数增1//
{
int i,n=0;
double k;
printf("\t\t请输入第%d个学生的学号(输入为0时结束输入):",n+1);
scanf("%d",&p[n].num);
while(p[n].num!=0) //当输入学号为0时,结束输入数据//
{
printf("\t\t请输入第%d个学生的姓名:",n+1);
scanf("%s",p[n].name);
printf("\t\t请输入第%d个学生的性别:",n+1);
scanf("%s",p[n].sex);
printf("\t\t请输入第%d个学生的班级:",n+1);
scanf("%s",p[n].clas);
for(i=0;i<3;i++)
{
printf("\t\t请输入第%d个学生的第%d门课程成绩:",n+1,i+1);
scanf("%lf",&k);
p[n].score[i]=k;
}
n++; //人数增1//
printf("\t\t请输入第%d个学生的学号(输入为0时结束输入):",n+1);
scanf("%d",&p[n].num);
}
return n; //将人数返回主调函数//
}
void modi(struct student p[SIZE],int n) //修改记录函数//
{
int i,j,c,no;
int flag1=0; //flag1标志是否查找该学号的学生记录//
printf("\t\t请输入要修改数据的学生的学号:");
scanf("%d",&no);
for(i=0;i<n;i++) //查找,找到,标志变量flag1置1//
{
if(p[i].num==no)
{
flag1=1;
break; //找到后,中断查找,该学号学生记录下标为i //
}
}
if(flag1==1) //查找到就修改该记录信息,否则报告查找失败//
{
do //可以对找到的记录多项次修改//
{
modimenu();
scanf("%d",&c);
switch(c)
{
case 1: printf("\t\t请输入新的学号:"); scanf("%d",&p[i].num); break;
case 2: printf("\t\t请输入新的姓名:"); scanf("%s",p[i].name); break;
case 3: printf("\t\t请输入新的性别:"); scanf("%s",p[i].sex); break;
case 4: printf("\t\t请输入新的班级:"); scanf("%s",p[i].clas); break;
case 5: printf("\t\t请输入新的语文成绩:"); scanf("%lf",&p[i].score[0]); break;
case 6: printf("\t\t请输入新的数学成绩:"); scanf("%lf",&p[i].score[1]); break;
case 7: printf("\t\t请输入新的英语成绩:"); scanf("%lf",&p[i].score[2]); break;
case 8: break;
default:printf("\t\t选择无效,请重新选择:\n"); break;
}
}while(c!=8);
printf("\t\t该生新的各项信息为:\n"); //修改结束后,输出修改后的该生信息//
printf("\t\t学号\t姓名\t性别\t班级\t语文\t数学\t英语\n");
printf("\t\t----------------------------------------------------\n");
printf("\t\t%d\t%s\t%s\t%s",p[i].num,p[i].name,p[i].sex,p[i].clas);
for(j=0;j<3;j++)
printf("\t%5.1lf",p[i].score[j]);
printf("\n");
}else printf("\t\t无该学号学生记录!\n");
}
void deal(struct student p[SIZE],int n) //数据处理函数//
{
int c;
do
{