没看答案的恶果,做了一上午外加晚上一小时
程序代码:
#include<stdio.h> int main() { int a[10] = { 0,1,2,3,4,5,6,7,8,9 }; int i = 0, j = 0, n = 0, m = 2, h = 10, r, s; for (i = 0; i < 10; i++) printf("%d ", a[i]); printf("\n"); for (r = 5; r > 0; r--) { i = 0; while (j < h) { a[i++] = a[j++]; n = i; if (j == m) { j++; m = m + 3; } } h = n; if (m == j + 2) { m = 3; j = 1; } else if (m == j + 1) { m = 1; j = 0; } s = n; for (i = 0; i < s; i++) printf("%d ", a[i]); printf("\n"); n = 0; } return 0; }