#include<stdio.h> int main() { int arr[11] = { 0,25,12,36,45,2,9,39,22,98,37 }; int i, j, k; for (k = 1; k < 11; k++) { printf("%d\t", arr[k]); } printf("\n"); for (i = 2; i <= 10; i++) { arr[0] = arr[i]; printf("a[0]%d\t\n", arr[0]); j = i - 1; while (arr[0] < arr[j]) { arr[j + 1] = arr[j]; printf("a[j+1]%d=a[j]%d\t", arr[j+1],arr[j]); j--; } printf("\n"); for (k = 1; k < 11; k++) { printf("%d\t", arr[k]); } printf("\n"); arr[j + 1] = arr[0]; } printf("\n"); for (k = 1; k < 11; k++) { printf("%d\t", arr[k]); } return 0; }
时间: 2024-11-10 15:03:10