runnig

indices of sorted array

Mar 15th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <vector>
  2. #include <utility>
  3. #include <algorithm>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7. int main()
  8. {
  9.     const int N = 4;
  10.     int input[] = { 4, 3, 2, 1 };
  11.  
  12.     vector< pair< int , int > > vec(N);
  13.     for(int i = 0; i < N; ++i) { vec[i] = make_pair(input[i], i); }
  14.     sort(vec.begin(), vec.end());
  15.  
  16.     for(int i = 0; i < N; ++i) { cout << vec[i].second; }
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment