typedef struct {
int id;
int weight;
int height;
} Body;
void swap(Body *a, Body *b) {
Body w = *a;
*a = *b;
*b = w;
}
int main() {
Body a[] = {
{1, 65, 169},
{2, 73, 170},
{3, 59, 161},
{4, 79, 175},
{5, 55, 168},
};
printf("ID\tWeight\tHeight\n");
for (int i = 0; i <5; i++) {
for (int j = 0; j < 4; j++) {
if (a[i].height < a[j+1].height) {
swap(&a[i], &a[j+1]);
}
if (a[j].height < a[j + 1].height) {
swap(&a[j], &a[j + 1]);
}
} printf("%d\t%d\t%d\n", a
[i
].
id, a
[i
].
weight, a
[i
].
height);
}
return 0;
}
dHlwZWRlZiBzdHJ1Y3QgewogICAgaW50IGlkOyAgICAgICAKICAgIGludCB3ZWlnaHQ7ICAgCiAgICBpbnQgaGVpZ2h0OyAgIAp9IEJvZHk7CiAKIAp2b2lkIHN3YXAoQm9keSAqYSwgQm9keSAqYikgewogICAgQm9keSB3ID0gKmE7CiAgICAqYSA9ICpiOwogICAgKmIgPSB3Owp9CiAKaW50IG1haW4oKSB7CiAKICAgIEJvZHkgYVtdID0gewogICAgICAgIHsxLCA2NSwgMTY5fSwgIAogICAgICAgIHsyLCA3MywgMTcwfSwgIAogICAgICAgIHszLCA1OSwgMTYxfSwgIAogICAgICAgIHs0LCA3OSwgMTc1fSwKICAgICAgICB7NSwgNTUsIDE2OH0sCiAgICB9OwogCiAKIHByaW50ZigiSURcdFdlaWdodFx0SGVpZ2h0XG4iKTsKICAgCiAKICAgIGZvciAoaW50IGkgPSAwOyBpIDw1OyBpKyspIHsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IDQ7IGorKykgewogICAgICAgIAkJaWYgKGFbaV0uaGVpZ2h0IDwgYVtqKzFdLmhlaWdodCkgeyAgCiAgICAgICAgICAgICAgICBzd2FwKCZhW2ldLCAmYVtqKzFdKTsgIAogICAgICAgICAgICB9IAogICAgICAgICAgICBpZiAoYVtqXS5oZWlnaHQgPCBhW2ogKyAxXS5oZWlnaHQpIHsgIAogICAgICAgICAgICAgICAgc3dhcCgmYVtqXSwgJmFbaiArIDFdKTsgIAogICAgICAgICAgICB9IAogICAgICAgIH0gcHJpbnRmKCIlZFx0JWRcdCVkXG4iLCBhW2ldLmlkLCBhW2ldLndlaWdodCwgYVtpXS5oZWlnaHQpOwogICAgICAgIAogICAgfQogICAgCiAKICAgIHJldHVybiAwOwp9