- 首页 > it技术 > >
STL应用之输入任意个整数,并按从大到小排序并输入
#include
#include
#include
#include
using namespace std;
bool compas( const int &a, const int &b)
{
return a>b;
}
int main()
{
typedef vector int_vector;
typedef istream_iterator in_istream_iterator;
typedef ostream_iterator out_ostream_iterator;
typedef back_insert_iterator > back_iterator;
int_vector myint;
copy(in_istream_iterator(cin),in_istream_iterator(),back_iterator(myint));
sort(myint.begin(),myint.end(),compas);
copy(myint.begin(),myint.end(),out_ostream_iterator(cout,"\n"));
return 0;
}
推荐阅读