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