vector

#include <iostream> //从小到大排列
#include<algorithm>
#include<vector>
using namespace std;

int main()

{ int i,x;
vector<int>my ;
for(i=1;i<=10; i++)
{
cin>>x;

my.push_back(x);
}


sort(my.begin(),my.end());


for(i=0;i<10;i++)
cout<<my[i]<<" " ;

}

 

 

 

 

 

 

 

 

 

 


#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;


bool cmp(const int &a,const int &b)
{ if(a!=b) return a>b; else return a>b ; }

int main()

{ int i,x;
vector<int>my ;
for(i=1;i<=10; i++)
{
cin>>x; my.push_back(x);
}
sort(my.begin(),my.end(),cmp);
for(i=0;i<10;i++)
cout<<my[i]<<" " ;

}

 

 

 

 

 

 

posted @ 2014-08-10 17:47  2014acm  阅读(97)  评论(0编辑  收藏  举报