#include <stdio.h>
typedef struct {
int id;
int weight;
int height;
} Body;
void swap(Body data[]);
void display(Body data[]);
int main(void) {
Body data[] = {
{1, 65, 169},
{2, 73, 170},
{3, 59, 161},
{4, 79, 175},
{5, 55, 168}
};
swap(data);
display(data);
return 0;
}
void swap(Body data[]) {
Body temp;
temp = data[0];
data[0] = data[4];
data[4] = temp;
temp = data[1];
data[1] = data[3];
data[3] = temp;
}
void display(Body data[]) {
for (int i = 0; i < 5; i++) {
printf("ID: %d, Weight: %d, Height: %d\n", data
[i
].
id, data
[i
].
weight, data
[i
].
height); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICBpbnQgaWQ7CiAgICBpbnQgd2VpZ2h0OwogICAgaW50IGhlaWdodDsKfSBCb2R5OwoKdm9pZCBzd2FwKEJvZHkgZGF0YVtdKTsKdm9pZCBkaXNwbGF5KEJvZHkgZGF0YVtdKTsKCmludCBtYWluKHZvaWQpIHsKICAgIEJvZHkgZGF0YVtdID0gewogICAgICAgIHsxLCA2NSwgMTY5fSwKICAgICAgICB7MiwgNzMsIDE3MH0sCiAgICAgICAgezMsIDU5LCAxNjF9LAogICAgICAgIHs0LCA3OSwgMTc1fSwKICAgICAgICB7NSwgNTUsIDE2OH0KICAgIH07CiAgICAKICAgIHN3YXAoZGF0YSk7CiAgICBkaXNwbGF5KGRhdGEpOwoKICAgIHJldHVybiAwOwp9Cgp2b2lkIHN3YXAoQm9keSBkYXRhW10pIHsKICAgIEJvZHkgdGVtcDsKCiAgICB0ZW1wID0gZGF0YVswXTsKICAgIGRhdGFbMF0gPSBkYXRhWzRdOwogICAgZGF0YVs0XSA9IHRlbXA7CgogICAgdGVtcCA9IGRhdGFbMV07CiAgICBkYXRhWzFdID0gZGF0YVszXTsKICAgIGRhdGFbM10gPSB0ZW1wOwp9Cgp2b2lkIGRpc3BsYXkoQm9keSBkYXRhW10pIHsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNTsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCJJRDogJWQsIFdlaWdodDogJWQsIEhlaWdodDogJWRcbiIsIGRhdGFbaV0uaWQsIGRhdGFbaV0ud2VpZ2h0LCBkYXRhW2ldLmhlaWdodCk7CiAgICB9Cn0K
ID: 5, Weight: 55, Height: 168
ID: 4, Weight: 79, Height: 175
ID: 3, Weight: 59, Height: 161
ID: 2, Weight: 73, Height: 170
ID: 1, Weight: 65, Height: 169