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 35 36 37 38 39 40 41 42 43 44 45 46 | #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> float swap_array(int num1[], int num2[], int n); void print_array(int num[], int n); int main(void) { int numbers1[5] = { 10, 20, 30, 40, 50 }; int numbers2[5] = { 60, 70, 80, 90, 100 }; printf("swap Àü\n"); printf("numbers1[5]:"); print_array(numbers1,5); printf("numbers2[5]:"); print_array(numbers2,5); swap_array(numbers1, numbers2, sizeof(numbers1) / sizeof(numbers1[0])); printf("swap ÈÄ\n"); printf("numbers1[5]:"); print_array(numbers1,5); printf("numbers2[5]:"); print_array(numbers2,5); } float swap_array(int *p1, int *p2, int n) { for (int i = 0; i < 5; i++) { int temp = *p1; *p1 = *p2; *p2 = temp; p1++; p2++; } } void print_array(int num[], int n) { for (int i = 0; i < n; i++) { printf("%d ", num[i]); } printf("\n"); } | cs |