#include<iostream>
using namespace std;
int main()
{
int t;
int a[10];
cout<<"请输入十个数字"<<endl;
for(int i=0;i<10;i++)
cin>>a[i];
for(int j=0;j<9;j++)//十个数进行9趟比较
{
for(int i=0;i<9-j;i++)//每次进行9-j次比较
{
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
for(i=0;i<10;i++)
cout<<a[i]<<" ";
cout<<endl;
}
冒泡排序对输入的十个数字进行排序
猜你喜欢
转载自blog.csdn.net/m0_47575628/article/details/108944571
今日推荐
周排行