改进版
程序代码:
void sort(int a[], int b[], int m, int n) { int i = 0, j = m - n; while (i < n) b[i++] = a[j++]; j = 0; while (j < m - n) b[i++] = a[j++]; } #include<stdio.h> int main() { void sort(int a[], int b[], int m, int n); void(*p)(int a[], int b[], int m, int n) = NULL; int i; int a[10], b[10]; p = sort; for (i = 0; i < 10; i++) scanf_s("%d", &a[i]); (*p)(a, b, 10, 3); for (i = 0; i < 10; i++) printf("%d ", b[i]); printf("\n"); return 0; }