Advertisement
LuckyCipher

Untitled

Nov 7th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include<stack>
  3. #include<algorithm>
  4. #include<stdio.h>
  5.  
  6. #include <string>
  7. #include<array>
  8. using namespace std;
  9.  
  10.  
  11. stack <char> mys;
  12. struct Interval {
  13.     string A;
  14.     int  B;
  15.     int C;
  16.     float D;
  17.     int E;
  18. };
  19.  
  20.  
  21.  
  22.  
  23. bool compareInterval(Interval i1, Interval i2)
  24. {
  25.     char temp;
  26.     temp = mys.top();
  27.     if(temp == 'A'){
  28.         if(i1.A.compare(i2.A) < 0)
  29.          return true;
  30.          else
  31.          return false;
  32.     }
  33.     else if(temp == 'B'){
  34.         return (i1.B < i2.B);
  35.     }
  36.     else if(temp == 'C'){
  37.         return (i1.C < i2.C);
  38.     }
  39.     else if(temp == 'D'){
  40.         return (i1.D < i2.D);
  41.     }
  42.         else if(temp == 'E'){
  43.         return (i1.E < i2.E);
  44.     }
  45.    
  46. }
  47.  
  48.  
  49. int main()
  50. {
  51.    
  52.     int nn;
  53.     cin >> nn;
  54.     array <Interval,5> arr;
  55.     array <Interval,5> arr2;
  56.     for( int i=0;i<nn;i++){
  57.        
  58.         cin >> arr[i].A;
  59.         cin >> arr[i].B;
  60.         cin >> arr[i].C;
  61.         cin >> arr[i].D;
  62.         cin >> arr[i].E;
  63.     }
  64.    
  65.  
  66.  
  67.     bool firstTime = false;
  68.     int num;
  69.     char c;
  70.     cin >> num;
  71.     do{
  72.    
  73.         if(num != 0){
  74.              for(int i=0;i<num;i++){
  75.             cin >>c;
  76.             mys.push(c);
  77.      }
  78.  
  79. arr2 = arr;
  80.      while(!mys.empty())
  81.       {
  82.        
  83.          stable_sort(arr2.begin(), arr2.end(), compareInterval);
  84.          mys.pop();
  85.       }
  86.       if(firstTime == true)
  87.        cout << "\n\n";
  88.        
  89.        firstTime = true;
  90.        for (int i = 0; i < 5; i++)
  91.         {if
  92.         (i==0)
  93.         cout  << arr2[i].A;
  94.         else
  95.         cout << endl << arr2[i].A;
  96.         }
  97.          }
  98.    
  99.  
  100.     cin >> num;      
  101.     }while(!num == 0);
  102.    
  103.    
  104.    
  105.        
  106.    
  107.    
  108.    
  109.  
  110.    
  111.  
  112.     return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement