请高手编道:计算并打印班级记分排名

来源:百度知道 编辑:UC知道 时间:2024/05/17 09:16:29
条件:
1.假设有10人的班,考3科
2.比如数学,语文,英语,3科目.要在程序运行的时候可以选择哪项分数最高排第一
3.并且按顺序打印在屏幕上
4.谢谢撒~~``

#include<stdio.h>

//结构的定义
typedef struct
{
long no;
char name[20];
double score[3];
}Student;

void GetOneRecord(Student students[],int i)
{//将第i个学生的信息录入到students[i]中
printf("Input the NO.:");scanf("%ld",&students[i].no);
printf("Input the name:");scanf("%s",students[i].name);
printf("Input the first score:");scanf("%lf",&students[i].score[0]);
printf("Input the second score:");scanf("%lf",&students[i].score[1]);
printf("Input the third score:");scanf("%lf",&students[i].score[2]);
}

void OutputTableHead()
{//打印表头
printf("学号 姓名 成绩1 成绩2 成绩3\n");
}

void OutputOneRecord(Student students[],int i)
{
printf("%ld\t%s\t%.2lf\t%.2lf\t%.2lf\t",students[i].no,students[i].name,students[i].score[0],students[i