forked from pi7mcrg2k/ScoreManagementSystem
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
67 lines
1.6 KiB
2 weeks ago
|
#include <stdio.h>
|
||
|
|
||
|
struct Data
|
||
|
{
|
||
|
int ID;
|
||
|
float score1;
|
||
|
float score2;
|
||
|
float score3;
|
||
|
} stu[1001];
|
||
|
int stl = 0, sortstl;
|
||
|
|
||
|
float total(struct Data* a) {
|
||
|
return a->score1 + a->score2 + a->score3;
|
||
|
}
|
||
|
|
||
|
void swap(struct Data* a, struct Data* b) {
|
||
|
struct Data t = *a;
|
||
|
*a = *b;
|
||
|
*b = t;
|
||
|
}
|
||
|
|
||
|
void input1() {
|
||
|
scanf("%d", &stu[stl].ID);
|
||
|
scanf("%f", &stu[stl].score1);
|
||
|
scanf("%f", &stu[stl].score2);
|
||
|
scanf("%f", &stu[stl].score3);
|
||
|
stl++;
|
||
|
}
|
||
|
|
||
|
|
||
|
void Input() {
|
||
|
printf("Please input info of three students:\n");
|
||
|
input1();input1();input1();
|
||
|
if (total(&stu[stl-3]) < total(&stu[stl-2])) swap(&stu[stl-3], &stu[stl-2]);
|
||
|
if (total(&stu[stl-2]) < total(&stu[stl-1])) swap(&stu[stl-2], &stu[stl-1]);
|
||
|
if (total(&stu[stl-3]) < total(&stu[stl-2])) swap(&stu[stl-3], &stu[stl-2]);
|
||
|
printf("%d,%.1f,%.1f\n", stu[stl-3].ID, total(&stu[stl-3]), total(&stu[stl-3])/3.0f);
|
||
|
printf("%d,%.1f,%.1f\n", stu[stl-2].ID, total(&stu[stl-2]), total(&stu[stl-2])/3.0f);
|
||
|
printf("%d,%.1f,%.1f\n", stu[stl-1].ID, total(&stu[stl-1]), total(&stu[stl-1])/3.0f);
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
printf(" 1.Input\n");
|
||
|
printf(" 2.Output\n");
|
||
|
printf(" 3.Order\n");
|
||
|
printf(" 4.Quit\n");
|
||
|
char t;
|
||
|
scanf("%c", &t);
|
||
|
switch(t) {
|
||
|
case 'i':
|
||
|
printf("You are trying to Input info\n");
|
||
|
Input();
|
||
|
break;
|
||
|
case 'o':
|
||
|
printf("You are trying to Output info\n");
|
||
|
break;
|
||
|
case 'm':
|
||
|
printf("You are trying to Make things ordered\n");
|
||
|
break;
|
||
|
case 'q':
|
||
|
printf("You are trying to Quit\n");
|
||
|
break;
|
||
|
default:
|
||
|
printf("Wrong input\n");
|
||
|
break;
|
||
|
}
|
||
|
}
|