int bubble_sort(int data[], int len)
{
int i = 0;
int j = 0;
int temp = 0;
for(i=0; i<len; i++)
{
for(j=0; j<len-i-1; j++)
{
if(data[j] > data[j+1])
{
#if 0
temp = data[j];
data[j] = data[j+1];
data[j+1] = temp;
#endif
data[j] = data[j]+data[j+1];
data[j+1] = data[j]-data[j+1];
data[j] = data[j]-data[j+1];
}
}
}
return 0;
}
冒泡排序算法
最新推荐文章于 2024-09-27 11:50:10 发布