《C语言程序设计》实验报告

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:36:05
实验题目:
输入一个班10个学生的学号和每个学生考试三门功课(数学、英语、计算机基础)的成绩。编程计算出每个学生的总分和平均分,并按学生成绩优劣排序,最后打印一张按高分到低分名次排序的成绩单。要求:
1)排序用一个函数实现。
2)打印的成绩单表项包括:序号,学号、数学、英语、计算机、总分、平均分。
3)按实验报告电子模板格式填写实验内容。

哥哥你太浪漫了,这么难得题!

使用结构数组...短多啦
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include<stdio.h>
struct stuScore
{
char name[20];
int number;
float math;
float comp;
};
void main()
{int i;
float sum[5];
stuScore st[5];
printf("请输入5位学生的学号、姓名、数学成绩、计算机成绩\n");
for(i=0;i<5;i++)
scanf("%d%s%f%f",&st[i].number,st[i].name,&st[i].math,&st[i].comp);
printf("学号\t姓名\t数学\t计算机\t总分\n");
for(i=0;i<5;i++)
{sum[i]=st[i].math+st[i].comp;
printf("%d\t%s\t%6.2f\t%6.2f\t%6.2f\n",st[i].number,st[i].name,st[i].math,st[i].comp,sum[i]);
}
}

使用结构变量,没有使用结构数组...恶长...
#include<stdio.h>
struct stuScore
{
char name[20];
int number;
float math;
float comp;
};
void main()
{float sum1,sum2,sum3,sum4,sum5;
stu