很多~冒泡,插入,选择,合并,快速,堆,希尔,哈希……
#include<iostream>
#include<string>
using namespace std;
int main()
{
int a,b,c,d,e,f,temp=0;
int t[100];
cout << "please input the number of the data : ";
while(cin>>a)
{
for(f=0;f<100;f++)
t[f]=0;
for(b=0;b<a;b++)
cin >> t[b];
for(c=0;c<a;c++)
{
for(d=0;d<a-c;d++)
{
if(t[d]>t[d+1])
{
temp=t[d];
t[d]=t[d+1];
t[d+1]=temp;
}
}
}
cout << "the answer is : ";
for(e=1;e<=a;e++)
cout << t[e]<<" ";
cout << endl <<"pelase input the number of the next date : ";
}
return 0;
}