#include <stdio.h>
typedef struct {
int id; // 学籍番号
double height; // 身長
} Student;
void sort(Student* p)
{
Student t;
int i;
int flag;
do {
flag = 0;
for (i = 0; i < 4; i++) {
if (p[i].height > p[i+1].height) {
t = p[i];
p[i] = p[i+1];
p[i+1] = t;
flag = 1;
}
}
} while (flag);
}
int main()
{
Student student[5];
int i;
for (i = 0; i < 5; i++) {
scanf("%d", &student
[i
].
id); scanf("%lf", &student
[i
].
height); }
sort(student);
printf("身長によるソート結果は以下の様になります.\n"); for (i = 0; i < 5; i++) {
printf("学籍番号%2d 身長%f\n", student
[i
].
id, student
[i
].
height); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCB7CglpbnQJaWQ7CS8vIOWtpuexjeeVquWPtwoJZG91YmxlCWhlaWdodDsJLy8g6Lqr6ZW3Cn0gU3R1ZGVudDsKCnZvaWQgc29ydChTdHVkZW50KiBwKQp7CglTdHVkZW50CXQ7CglpbnQJaTsKCWludAlmbGFnOwoKCWRvIHsKCQlmbGFnID0gMDsKCQlmb3IgKGkgPSAwOyBpIDwgNDsgaSsrKSB7CgkJCWlmIChwW2ldLmhlaWdodCA+IHBbaSsxXS5oZWlnaHQpIHsKCQkJCXQgPSBwW2ldOwoJCQkJcFtpXSA9IHBbaSsxXTsKCQkJCXBbaSsxXSA9IHQ7CgkJCQlmbGFnID0gMTsKCQkJfQoJCX0KCX0gd2hpbGUgKGZsYWcpOwp9CgppbnQgbWFpbigpCnsKCVN0dWRlbnQJc3R1ZGVudFs1XTsKCWludAlpOwoKCWZvciAoaSA9IDA7IGkgPCA1OyBpKyspIHsKCQlwcmludGYoIiVk5Lq655uu77yaXG4iLCBpICsgMSk7CgkJcHJpbnRmKCLlrabnsY3nlarlj7fvvJpcbiIpOwoJCXNjYW5mKCIlZCIsICZzdHVkZW50W2ldLmlkKTsKCQlwcmludGYoIui6q+mVt++8mlxuIik7CgkJc2NhbmYoIiVsZiIsICZzdHVkZW50W2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