Sort a subset of the container

Started by aruljothi, Jun 11, 2009, 10:00 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()+2, v.end()-2);

  show("sorting elements v[2] to v[7] 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;
 
}

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview