将数组{8,23,4,16,77,-5,53,100}中的元素按从小到大的顺序排列,每次可以交换任意两个元素,最少需

问题描述:

将数组{8,23,4,16,77,-5,53,100}中的元素按从小到大的顺序排列,每次可以交换任意两个元素,最少需
交换几次?

change 1
change 2
change 3
change 4
change 5
change 6
change 7
change 8
change 9
total change 9
-5 4 8 16 23 53 77 100
Press any key to continue这个神马意思。。求教大虾在每个交换后面加个输出 和累加输出的就是这样#includeint main(){ int i,j,tmp,flag=1,change=0; int a[8]={8,23,4,16,77,-5,53,100}; for (i=0;ia[j+1]) {tmp = a[j];a[j] = a[j+1];a[j+1] = tmp;change++;flag=0;printf("change %d\n",change); }}if(1 == flag) break; } printf("total change %d\n",change); for (i=0;i