Advertisement
ShafiulAzim

uva 11942

Feb 3rd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. void is_sortedA(int size,int arr[]);
  4. void is_sortedB(int size,int arr[]);
  5. bool f,g;
  6. void is_sortedA(int size,int arr[])
  7. {
  8. if(size<=1)
  9. return ;
  10. else
  11. {
  12. if(arr[size-1]>arr[size-2])
  13. is_sortedA(size-1,arr);
  14. else{
  15. f=false;
  16. return ;
  17. }
  18.  
  19. }
  20. }
  21.  
  22. void is_sortedB(int size,int arr[])
  23. {
  24. if(size<=1)
  25. return ;
  26. else
  27. {
  28. if(arr[size-1]<arr[size-2])
  29. is_sortedB(size-1,arr);
  30. else{
  31. g=false;
  32. return;
  33. }
  34. }
  35. }
  36. int main()
  37. {
  38. int n,i,arr[100],p;
  39. queue<string>q;
  40. cin>>n;
  41. while(n--)
  42. {
  43. for(i=0; i<10; i++)
  44. {
  45. cin>>arr[i];
  46. }
  47. f=true;
  48. g=true;
  49. is_sortedA(10,arr);
  50. is_sortedB(10,arr);
  51. if(f==true || g==true)
  52. q.push("Ordered");
  53. else
  54. q.push("Unordered");
  55. }
  56. cout<<"Lumberjacks:"<<endl;
  57. p=q.size();
  58. while(p--)
  59. {
  60. cout<<q.front()<<endl;
  61. q.pop();
  62. }
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement