#include <stdio.h>
struct Body {
int id;
int weight;
int height;
};
void swap(struct Body *a, struct Body *b) {
struct Body temp = *a;
*a = *b;
*b = temp;
}
int main() {
struct 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\t%d\t%d\n", a
[i
].
id, a
[i
].
weight, a
[i
].
height); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdHJ1Y3QgQm9keSB7CiAgaW50IGlkOwogIGludCB3ZWlnaHQ7CiAgaW50IGhlaWdodDsKfTsKCnZvaWQgc3dhcChzdHJ1Y3QgQm9keSAqYSwgc3RydWN0IEJvZHkgKmIpIHsKICBzdHJ1Y3QgQm9keSB0ZW1wID0gKmE7CiAgKmEgPSAqYjsKICAqYiA9IHRlbXA7Cn0KCmludCBtYWluKCkgewogIHN0cnVjdCBCb2R5IGFbXSA9IHsKICAgIHsxLCA2NSwgMTY5fSwKICAgIHsyLCA3MywgMTcwfSwKICAgIHszLCA1OSwgMTYxfSwKICAgIHs0LCA3OSwgMTc1fSwKICAgIHs1LCA1NSwgMTY4fSwKICB9OwoKICBpbnQgbiA9IHNpemVvZihhKSAvIHNpemVvZihhWzBdKTsKICAKICBmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKICAgIGZvciAoaW50IGogPSAwOyBqIDwgbiAtIGkgLSAxOyBqKyspIHsKICAgICAgaWYgKGFbal0uaGVpZ2h0IDwgYVtqICsgMV0uaGVpZ2h0KSB7CiAgICAgICAgc3dhcCgmYVtqXSwgJmFbaiArIDFdKTsKICAgICAgfQogICAgfQogIH0KCiAgcHJpbnRmKCJJRFx05L2T6YeNXHTouqvplbdcbiIpOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICBwcmludGYoIiVkXHQlZFx0JWRcbiIsIGFbaV0uaWQsIGFbaV0ud2VpZ2h0LCBhW2ldLmhlaWdodCk7CiAgfQoKICByZXR1cm4gMDsKfQ==