#include <stdio.h>
typedef struct {
int id;
int weight;
int height;
} Body;
void swap(Body *a, Body *b) {
Body x = *a;
*a = *b;
*b = x;
}
int main() {
Body a[] = {
{1, 65, 169},
{2, 73, 170},
{3, 59, 161},
{4, 79, 175},
{5, 55, 168}
};
int n = sizeof(a) / sizeof(a[0]);
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (a[j].height < a[j + 1].height) {
swap(&a[j], &a[j + 1]);
}
}
}
for (int i = 0; i < n; i++) {
printf("%d, %d, %d\n", a
[i
].
id, a
[i
].
weight, a
[i
].
height); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBpbnQgaWQ7CiAgICBpbnQgd2VpZ2h0OwogICAgaW50IGhlaWdodDsKfSBCb2R5OwoKCnZvaWQgc3dhcChCb2R5ICphLCBCb2R5ICpiKSB7CiAgICBCb2R5IHggPSAqYTsKICAgICphID0gKmI7CiAgICAqYiA9IHg7Cn0KCmludCBtYWluKCkgewogICAgCiAgICBCb2R5IGFbXSA9IHsKICAgICAgICB7MSwgNjUsIDE2OX0sCiAgICAgICAgezIsIDczLCAxNzB9LAogICAgICAgIHszLCA1OSwgMTYxfSwKICAgICAgICB7NCwgNzksIDE3NX0sCiAgICAgICAgezUsIDU1LCAxNjh9CiAgICB9OwoKICAgIGludCBuID0gc2l6ZW9mKGEpIC8gc2l6ZW9mKGFbMF0pOwoKICAgCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG4gLSBpIC0gMTsgaisrKSB7CiAgICAgICAgICAgIGlmIChhW2pdLmhlaWdodCA8IGFbaiArIDFdLmhlaWdodCkgewogICAgICAgICAgICAgICAgc3dhcCgmYVtqXSwgJmFbaiArIDFdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICAKICAgIHByaW50ZigiSUQgIOS9k+mHjSAg6Lqr6ZW3XG4iKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCIlZCwgICVkLCAgJWRcbiIsIGFbaV0uaWQsIGFbaV0ud2VpZ2h0LCBhW2ldLmhlaWdodCk7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0KCg==
ID 体重 身長
4, 79, 175
2, 73, 170
1, 65, 169
5, 55, 168
3, 59, 161