通过冒泡排序算法对数组?
参考代码:
int i, j, tmp;
int b[]={18,24,12,59,101,96,34};
for(i = 0; i < 6; i++)
for(j = i + 1; j < 7 ; j++)
{
if(b[i] > b[j])
tmp = b[i];
b[i] = b[j];
b[j] = tmp;
}
i = 0;
while(i++ < 7)
printf("%d ", b[i - 1]);