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