Advertisement
tobast

Untitled

Nov 5th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. struct Emplacement {
  6.     int emplacement;
  7.     int marchand;
  8.  
  9.     bool operator<(const Emplacement& e) const
  10.     {
  11.         return (marchand < e.marchand);
  12.     }
  13. };
  14.  
  15. int main(void)
  16. {
  17.     int nbMarchands;
  18.     cin >> nbMarchands;
  19.  
  20.     Emplacement emplacements[nbMarchands];
  21.  
  22.     for(int emplacement = 0; emplacement < nbMarchands; emplacement++)
  23.     {
  24.         int marchand;
  25.         cin >> marchand;
  26.         emplacements[emplacement].marchand = marchand;
  27.         emplacements[emplacement].emplacement = emplacement;
  28.     }
  29.  
  30.     sort(emplacements, emplacements+nbMarchands);
  31.  
  32.     for(int marchand=0; marchand < nbMarchands; marchand++)
  33.         cout << emplacements[marchand].emplacement << '\n';
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement