我是C/C++初学者
这是个用devc++写的冒泡排序算法:
#include<iostream.h>//冒泡排序
int main()
{ int num[10];
cout<<"输入10个数 用空格隔开"<<endl;
for(int i=0;i<10;i++)
cin>>num[i];
int temp;
for(int j=0;j<9;j++)
{
for(int a=j;a<9;a++)
{
if(num[j]>=num[a+1])
{
temp=num[j];
num[j]=num[a+1];
num[a+1]=temp;
}
}
cout<<endl;
for(int b=0;b<=9;b++)
{
cout<<num[b]<<" ";
}
}
cout<<endl;
system("pause");
return 0;
}
用于学习和交流、请多指教 ;