News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Sort the entire container

Started by aruljothi, Jun 11, 2009, 09:59 PM

Previous topic - Next topic

aruljothi

 
#include <cstdlib>
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

void show(const char *msg, vector<int> vect);

int main()
{
  vector<int> v(10);
  for(unsigned i=0; i < v.size(); i++)
    v = rand() % 100;

  show("Original order:", v);

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

  show("Order after sorting into natural order:", v);

  return 0;
}

void show(const char *msg, vector<int> vect) {
  cout << msg << endl;
  for(unsigned i=0; i < vect.size(); ++i)
    cout << vect << endl;
}