64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
#include <stdio.h>
|
|
|
|
int id;
|
|
|
|
struct student {
|
|
int id, c;
|
|
float x, y, z;
|
|
float sum;
|
|
} stu[233];
|
|
|
|
// 交换数据函数,也可以手写 c=a a=b b=c
|
|
void swap(struct student* a, struct student* b) {
|
|
struct student c;
|
|
c = *a;
|
|
*a = *b;
|
|
*b = c;
|
|
}
|
|
|
|
// 排序函数
|
|
void sort() {
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int j = 0; j < 3 - i - 1; j++) {
|
|
if (stu[j].c > stu[j + 1].c || (stu[j].c == stu[j + 1].c && stu[j].sum > stu[j + 1].sum)) {
|
|
swap(&stu[j], &stu[j + 1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
// scanf("%d,%d,%f,%f,%f", &stu[0].c, &stu[0].id, &stu[0].x, &stu[0].y, &stu[0].z);
|
|
// scanf("%d,%d,%f,%f,%f", &stu[1].c, &stu[1].id, &stu[1].x, &stu[1].y, &stu[1].z);
|
|
stu[0].c = 11;
|
|
stu[0].id = 1001;
|
|
stu[0].x = 92.5;
|
|
stu[0].y = 82.5;
|
|
stu[0].z = 96;
|
|
|
|
stu[1].c = 12;
|
|
stu[1].id = 1002;
|
|
stu[1].x = 82.5;
|
|
stu[1].y = 87.5;
|
|
stu[1].z = 93.5;
|
|
|
|
stu[2].c = 13;
|
|
stu[2].id = 1003;
|
|
stu[2].x = 97;
|
|
stu[2].y = 84.5;
|
|
stu[2].z = 88.5;
|
|
|
|
scanf("%d", &id);
|
|
stu[0].sum = stu[0].x + stu[0].y + stu[0].z;
|
|
stu[1].sum = stu[1].x + stu[1].y + stu[1].z;
|
|
stu[2].sum = stu[2].x + stu[2].y + stu[2].z;
|
|
|
|
sort();
|
|
for (int i = 0; i < 3; i++) {
|
|
// 不输出要删除的学生
|
|
if (stu[i].id == id)
|
|
continue;
|
|
printf("%d,%d,%.1f,%.1f,%.1f,%.1f\n", stu[i].id, stu[i].c, stu[i].x, stu[i].y, stu[i].z, stu[i].sum);
|
|
}
|
|
return 0;
|
|
} |