学生成绩管理系统(数据的处理)

下面是数据的处理的代码:










#include
#include
#include
#include
#include"qtsm.h"




void count()
{
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
list1->sum= list1->math+list1->chi+ list1->Eng+ list1->phy+ list1->chem;
list1->average = list1->sum / 5;
}
}
void sort_list()
{

infor*list;
infor*list1;
infor*list2;
int n = 0;
printf("下面开始排序!\n按学号排序请按  1\n按总分排序请按  2\n");
scanf("%d", &n);
if(n==1)
{
for (list = head; list != NULL; list = list->next)
{
for (list1 = head->next,list2=head; list1 != NULL; list2=list1,list1 = list1->next)
{
if (strcmp(list2->number,list1->number)>=0)
{
exchange_infor(list2, list1);
}
}
}
int i = 1;
for (list = head; list != NULL; list = list->next)
{
list->rank = i++;
}
int mm = 0;
printf("排序完成!是否要输出?\n");
printf("输出请按  1\n下一步请按  0\n");
scanf("%d",&mm);
if (mm)  stdout_infor();
}
if (n == 2)
{
         for (list = head; list != NULL; list = list->next)
            {
          for (list1 = head->next, list2 = head; list1 != NULL; list2 = list1, list1 = list1->next)
             {
    if (list2->sum < list1->sum)
    {
  exchange_infor(list2, list1);
    }
             }
           }
int i = 1;
for (list = head; list != NULL; list = list->next)
{
list->rank = i++;
}
int mm = 0;
printf("排序完成!是否要输出?\n");
printf("输出请按  1\n下一步请按  0\n");
scanf("%d", &mm);
if (mm)  stdout_infor();
}


}
void exchange_infor(infor *h1, infor*h2)
{
char number[30];
char name[30];
char gender[10];
int math;
int chi;
int Eng;
int phy;
int chem;
double average;
int sum;
int rank;
strcpy(number , h1->number);
strcpy(name, h1->name);
strcpy(gender, h1->gender);
math = h1->math;
chi = h1->chi;
Eng = h1->Eng;
phy = h1->phy;
chem = h1->chem;
average = h1->average;
sum = h1->sum;
rank = h1->rank;
//---------------------------------------------------------------------------------
strcpy(h1->number, h2->number );
strcpy(h1->name, h2->name );
strcpy(h1->gender, h2->gender );
h1->math= h2->math;
h1->chi= h2->chi;
h1->Eng = h2->Eng;
h1->phy= h2->phy;
h1->chem= h2->chem;
h1->average= h2->average;
h1->sum= h2->sum;
h1->rank = h2->rank;
//-------------------------------------------------------------------
strcpy(h2->number,number );
strcpy(h2->name,name );
strcpy(h2->gender,gender );
h2->math=math;
h2->chi= chi;
h2->Eng = Eng;
h2->phy=phy;
h2->chem=chem;
h2->average=average;
h2->sum=sum;
h2->rank =rank;
}
void count_average()
{
printf("下面开始计算各科平均成绩!\n");
int i = 0;
int a1=0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
double aa1, aa2, aa3, aa4, aa5, aa6,ii;
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
a1 +=list1->math;
a2 += list1->chi ;
a3 += list1->Eng ;
a4 += list1->phy ;
a5 += list1->chem ;
a6 += list1->sum ;
i++;
aa1 = (double)a1;
aa2 = (double)a2;
aa3 = (double)a3;
aa4 = (double)a4;
aa5 = (double)a5;
aa6 = (double)a6;
ii = (double)i;
}
//printf("%d\n", a2);
average[0] = aa1/ii;
average[1] = aa2 / ii;
average[2] = aa3 / ii;
average[3] = aa4 / ii;
average[4] = aa5 / ii;
average[5] = aa6 / ii;
printf("各科平均分为:     数学        语文       英语       物理       化学      总分\n");
printf("                   %.2lf      %.2lf    %.2lf      %.2lf     %.2lf     %.2lf\n", average[0], average[1], average[2], average[3], average[4], average[5]);
}
void show_lower()
{
while (1)
{

printf("下面显示某一科不足平均分的同学的所有信息!\n");
printf("1、数学科目请按  1\n2、语文科目请按  2\n3、英语科目请按  3\n4、物理科目请按  4\n5、化学科目请按  5\n下一步请按  0\n");
int n = 0;
scanf("%d", &n);
system("cls");
if (n == 1)
{

printf("下面输出数学科目不足平均分同学的所有信息!\n");
printf("姓名   学号        性别    数学   语文   英语   物理   化学   总分   平均分\n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->math {
printf("%3s   %s   %s   %3d    %3d   %3d    %3d    %3d    %3d     %.2lf\n", list1->name, list1->number, list1->gender, list1->math, list1->chi, list1->Eng, list1->phy, list1->chem, list1->sum, list1->average);
}
}
}
else if (n == 2)
{
printf("下面输出语文科目不足平均分同学的所有信息!\n");
printf("姓名   学号        性别    数学   语文   英语   物理   化学   总分   平均分\n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chi {
printf("%3s   %s   %s   %3d    %3d   %3d    %3d    %3d    %3d     %.2lf\n", list1->name, list1->number, list1->gender, list1->math, list1->chi, list1->Eng, list1->phy, list1->chem, list1->sum, list1->average);
}
}
}
else if (n == 3)
{
printf("下面输出英语科目不足平均分同学的所有信息!\n");
printf("姓名   学号        性别    数学   语文   英语   物理   化学   总分   平均分\n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->Eng {
printf("%3s   %s   %s   %3d    %3d   %3d    %3d    %3d    %3d     %.2lf\n", list1->name, list1->number, list1->gender, list1->math, list1->chi, list1->Eng, list1->phy, list1->chem, list1->sum, list1->average);
}
}
}
else if (n == 4)
{

printf("下面输出物理科目不足平均分同学的所有信息!\n");
printf("姓名   学号        性别    数学   语文   英语   物理   化学   总分   平均分\n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->phy {
printf("%3s   %s   %s   %3d    %3d   %3d    %3d    %3d    %3d     %.2lf\n", list1->name, list1->number, list1->gender, list1->math, list1->chi, list1->Eng, list1->phy, list1->chem, list1->sum, list1->average);
}
}
}
else if (n == 5)
{

printf("下面输出化学科目不足平均分同学的所有信息!\n");
printf("姓名   学号        性别    数学   语文   英语   物理   化学   总分   平均分\n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chem {
printf("%3s   %s   %s   %3d    %3d   %3d    %3d    %3d    %3d     %.2lf\n", list1->name, list1->number, list1->gender, list1->math, list1->chi, list1->Eng, list1->phy, list1->chem, list1->sum, list1->average);
}
}
}
else if (n == 0)
{

break;
}


}
}
void show_top()
{
while (1)
{
printf("下面显示某一科高于90分的同学的基本信息!\n");
printf("1、数学科目请按  1\n2、语文科目请按  2\n3、英语科目请按  3\n4、物理科目请按  4\n5、化学科目请按  5\n下一步请按  0\n");
int n = 0;
scanf("%d", &n);
system("cls");
if (n == 1)
{
printf("下面输出数学科目高于90分同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->math >= 90)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 2)
{


printf("下面输出语文科目高于90分同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chi >= 90)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 3)
{
printf("下面输出英语科目高于90分同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->Eng >= 90)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 4)
{
printf("下面输出物理科目高于90分同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->phy >= 90)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 5)
{
printf("下面输出化学科目高于90分同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chem>=90)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 0)
{
break;
}


}
}
void show_last()
{
while (1)
{
printf("下面显示某一科不及格同学的基本信息!\n");
printf("1、数学科目请按  1\n2、语文科目请按  2\n3、英语科目请按  3\n4、物理科目请按  4\n5、化学科目请按  5\n下一步请按  0\n");
int n = 0;
scanf("%d", &n);
system("cls");
if (n == 1)
{
printf("下面输出数学科目不及格同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->math <60)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 2)
{
printf("下面输出语文科目不及格同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chi <60)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 3)
{
printf("下面输出英语科目不及格同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->Eng <60)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 4)
{
printf("下面输出物理科目不及格同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->phy <60)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 5)
{
printf("下面输出化学科目不及格同学的基本信息!\n");
printf("姓名  学号           性别   \n");
for (infor *list1 = head; list1 != NULL; list1 = list1->next)
{
if (list1->chem <60)
{
printf("%3s   %s   %s\n", list1->name, list1->number, list1->gender);
}
}
}
else if (n == 0)
{
break;
}


}
}

你可能感兴趣的:(C语言学习)