| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include<stdio.h> struct student_info { char name[10]; int age; float weight; }; struct student_info students[4] = { {"È«±æµ¿", 504, 67.5}, {"À̼ø½Å", 703, 80.3}, {"°°¨Âù", 645, 77.0}, {"À¯°ü¼ø", 205, 56.5} }; void print_struct(struct student_info s[]) { for (int i = 0; i < 4; i++) { printf("%s %d %f\n", s[i].name, s[i].age, s[i].weight); } printf("\n"); } void swap(struct student_info s[]) { struct student_info tmp; tmp = s[1]; s[1] = s[0]; s[0] = tmp; } int main(void) { print_struct(students); swap(students); print_struct(students); } | cs |


struct_swap.png [35 KB]
struct_swap.txt [1 KB]
ÀڷᱸÁ¶ ½Ç½À°Ô½ÃÆÇ