Rakibul_Ahasan

Uva->11942 - Lumberjack Sequencing

Oct 10th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. /***
  2. **     Author: Rakibul Ahasan Papon
  3. **     Bangladesh University of Business and Technology,
  4. **     Dept. of CSE.
  5. ***/
  6.  
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     int t;
  13.     cin>>t;
  14.     cout<<"Lumberjacks:"<<endl;;
  15.     while(t--)
  16.     {
  17.         int ar[10],s[10],cnt=0,j=0;
  18.         for(int i=0; i<10; i++)
  19.         {
  20.             cin>>ar[i];
  21.             s[j]=ar[i];
  22.             j++;
  23.         }
  24.  
  25.         if(s[0]<s[9])
  26.         {
  27.             sort(s,s+10);
  28.             for(int i=0,j=0; i<10; i++,j++)
  29.             {
  30.                 if(ar[i]==s[j])
  31.                 {
  32.                     cnt++;
  33.                 }
  34.             }
  35.         }
  36.  
  37.         else
  38.         {
  39.             sort(s, s + 10, greater<int>());
  40.             for(int i=0,j=0; i<10; i++,j++)
  41.             {
  42.                 if(ar[i]==s[j])
  43.                 {
  44.                     cnt++;
  45.                 }
  46.             }
  47.  
  48.         }
  49.  
  50.         if(cnt==10)
  51.             cout<<"Ordered"<<endl;
  52.             else cout<<"Unordered"<<endl;
  53.  
  54.  
  55.     }
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment