//----数学中有乘法口诀。。那只是工具。我们都很熟悉。
//----C++中有一些基本的程序。也只是工具。我们必须像熟悉乘法口诀一样去熟悉这些程序。
//----很基础的一些东西,必须熟练。。。
//-======这些程序写的很粗糙。。。如果想用,请将其做进一步完善与修改。。。。
#include<iostream>
using namespace std;
int main()
{
void bubblesort(int a[],int n);
int a[10];
cout<<" input 10 numbers :"<<endl;
for(int i=0;i<10;i++)
cin>>a[i];
cout<<endl;
bubblesort(a,10);
cout<<" the sorted numbers:"<<endl;
for( i=0;i<10;i++)
cout<<a[i]<<" ";
cout<<endl;
return 0;
}
void bubblesort(int a[],int n) //--- 一维数组做参数
{
int t;
for(int j=0;j<9;j++)
for(inti=0;i<9-j;i++)
if(a[i]>a[i+1]) //------找出最大的数,让他下沉。。。。。。。。。。。
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}