在用冒泡排序对数5 30 25 15进行升序排序的过程中 进行了3次交换。 In the bubble sort ascending
已帮助 人
在用冒泡排序对数5、30、25、15进行升序排序的过程中,进行了3次交换。 In the bubble sort ascending order of number 5, 30, 25 and 15, three exchanges were made.

回答
共1条回复-
#include <stdio.h>
main()
{ int a[11],i,j,t;
printf("Input 10 numbers:
");
for(i=1;i<11;i++)
scanf("%d",&a[i]);
printf("
");
for(j=1;j<=9;j++)
for(i=1;i<=10-j;i++)
if(a[i]>a[i+1])
{t=a[i]; a[i]=a[i+1]; a[i+1]=t;}
printf("The sorted numbers:
");
for(i=1;i<11;i++)
printf("%d ",a[i]);
}
