#include <iostream>
using namespace std;
int main()
{
int a[10] = {4,5,8,2,7,3,9,5,7,1};
// int m = sizeof(a);
for (int j = 10; j > 0 ;j --)
{
for( int i = 0; i < j; i++)
{
if(a[i] > a[i+1])
{
int temp = 0;
temp = a[i];
a[i] = a [i+1];
a[i+1] = temp;
}
}
}
for(int i = 0; i < 10; i++)
{
cout << a[i] ;
}
return 0;
}
冒泡排序
最新推荐文章于 2022-04-29 23:24:15 发布