#include<stdio.h> void main() { int i,low=0,high=5,t,temp,k; int a[6]={8,7,5,6,4,1}; printf("origin

#include<stdio.h> void main() { int i,low=0,high=5,t,temp,k; int a[6]={8,7,5,6,4,1}; printf("origin
不会双向冒泡,不过
for(i=low;i {
if(a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
t=i;
}
high=t-1;这里,若if不成立,则t未初始化,high赋值无法确定。
若if成立,则high=t-1即=i-1,则下一次循环i }
← 上一篇: 下一篇: →