#include <stdio.h>
struct Body {
int id;
int weight;
int height;
};
void swapBody(struct Body *a, struct Body *b) {
struct Body w = *a;
*a = *b;
*b = w;
}
int main(void) {
struct Body a[] = {
{1, 65, 169},
{2, 73, 170},
{3, 59, 161},
{4, 79, 175},
{5, 55, 168}
};
int n = 5;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (a[i].height < a[j].height) {
swapBody(&a[i], &a[j]);
}
}
}
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+CiAKc3RydWN0IEJvZHkgewogICAgaW50IGlkOwogICAgaW50IHdlaWdodDsKICAgIGludCBoZWlnaHQ7Cn07CiAKIAp2b2lkIHN3YXBCb2R5KHN0cnVjdCBCb2R5ICphLCBzdHJ1Y3QgQm9keSAqYikgewogICAgc3RydWN0IEJvZHkgdyA9ICphOwogICAgKmEgPSAqYjsKICAgICpiID0gdzsKfQogCmludCBtYWluKHZvaWQpIHsKICAgIHN0cnVjdCBCb2R5IGFbXSA9IHsKICAgICAgICB7MSwgNjUsIDE2OX0sCiAgICAgICAgezIsIDczLCAxNzB9LAogICAgICAgIHszLCA1OSwgMTYxfSwKICAgICAgICB7NCwgNzksIDE3NX0sCiAgICAgICAgezUsIDU1LCAxNjh9CiAgICB9OwogICAgaW50IG4gPSA1OwogCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gaSArIDE7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgaWYgKGFbaV0uaGVpZ2h0IDwgYVtqXS5oZWlnaHQpIHsKICAgICAgICAgICAgICAgIHN3YXBCb2R5KCZhW2ldLCAmYVtqXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCIlZFx0JWRcdCVkXG4iLCBhW2ldLmlkLCBhW2ldLndlaWdodCwgYVtpXS5oZWlnaHQpOwogICAgfQogCiAgICByZXR1cm4gMDsKfQ==