#include <stdio.h>
struct Body {
int id;
int weight;
int height;
};
void swap(int *a, int *b) {
int w = *a;
*a = *b;
*b = w;
}
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+CiAKc3RydWN0IEJvZHkgewogICAgaW50IGlkOwogICAgaW50IHdlaWdodDsKICAgIGludCBoZWlnaHQ7Cn07CiAKdm9pZCBzd2FwKGludCAqYSwgaW50ICpiKSB7CiAgICBpbnQgdyA9ICphOwogICAgKmEgPSAqYjsKICAgICpiID0gdzsKfQogCnZvaWQgc3dhcEJvZHkoc3RydWN0IEJvZHkgKmEsIHN0cnVjdCBCb2R5ICpiKSB7CiAgICBzdHJ1Y3QgQm9keSB3ID0gKmE7CiAgICAqYSA9ICpiOwogICAgKmIgPSB3Owp9CiAKaW50IG1haW4odm9pZCkgewogICAgc3RydWN0IEJvZHkgYVtdID0gewogICAgICAgIHsxLCA2NSwgMTY5fSwKICAgICAgICB7MiwgNzMsIDE3MH0sCiAgICAgICAgezMsIDU5LCAxNjF9LAogICAgICAgIHs0LCA3OSwgMTc1fSwKICAgICAgICB7NSwgNTUsIDE2OH0KICAgIH07CiAgICBpbnQgbiA9IDU7CiAKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbiAtIDE7IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47IGorKykgewogICAgICAgICAgICBpZiAoYVtpXS5oZWlnaHQgPCBhW2pdLmhlaWdodCkgewogICAgICAgICAgICAgICAgc3dhcEJvZHkoJmFbaV0sICZhW2pdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBwcmludGYoIiVkXHQlZFx0JWRcbiIsIGFbaV0uaWQsIGFbaV0ud2VpZ2h0LCBhW2ldLmhlaWdodCk7CiAgICB9CiAKICAgIHJldHVybiAwOwp9