1 Replies - 1971 Views - Last Post: 02 March 2012 - 02:39 PM

#1 Xing   User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Sorting in descending order using sort & reverse iterators

Posted 31 July 2007 - 11:58 PM

Description:
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>


using std::cout;            using std::cin;
using std::sort;            using std::vector;
using std::ostream_iterator;using std::endl;



int main()
{
    vector<int> v;
    int val;
    while ( cin >> val, cin.good() )
    {
        v.push_back( val );
    }
    sort(v.rbegin(),v.rend());
    copy(v.begin(),v.end(),ostream_iterator<int>(cout," "));
    return 0;
}





Is This A Good Question/Topic? 0
  • +

Replies To: Sorting in descending order using sort & reverse iterators

#2 johnsurf   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 02-March 12

Re: Sorting in descending order using sort & reverse iterators

Posted 02 March 2012 - 02:39 PM

What condition causes the while loop to finish?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1