#include <stdio.h>
typedef struct {
int id;
int weight;
int height;
} Body;
void swap(Body *x, Body *y) {
Body temp = *x;
*x = *y;
*y = temp;
}
int main(void) {
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 = 0; j < n - 1 - i; 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+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBpbnQgaWQ7CiAgICBpbnQgd2VpZ2h0OwogICAgaW50IGhlaWdodDsKfSBCb2R5OwoKdm9pZCBzd2FwKEJvZHkgKngsIEJvZHkgKnkpIHsKICAgIEJvZHkgdGVtcCA9ICp4OwogICAgKnggPSAqeTsKICAgICp5ID0gdGVtcDsKfQoKaW50IG1haW4odm9pZCkgewogICAKICAgIEJvZHkgYVtdID0gewogICAgICAgIHsxLCA2NSwgMTY5fSwKICAgICAgICB7MiwgNzMsIDE3MH0sCiAgICAgICAgezMsIDU5LCAxNjF9LAogICAgICAgIHs0LCA3OSwgMTc1fSwKICAgICAgICB7NSwgNTUsIDE2OH0KICAgIH07CiBpbnQgbj01OwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBuIC0gMSAtIGk7IGorKykgewogICAgICAgICAgICBpZiAoYVtqXS5oZWlnaHQgPCBhW2orMV0uaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICBzd2FwKCZhW2pdLCAmYVtqKzFdKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIHByaW50ZigiJWQsICVkLCAlZFxuIiwgYVtpXS5pZCwgYVtpXS53ZWlnaHQsIGFbaV0uaGVpZ2h0KTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=
4, 79, 175
2, 73, 170
1, 65, 169
5, 55, 168
3, 59, 161