Guest User

Untitled

a guest
Nov 6th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3.  
  4. using namespace std;
  5.  
  6. // bool isSorted(vector<int> a, n){
  7. bool isSorted(int *a, int n){
  8.     if(n== 1){
  9.         return true;
  10.     }
  11.    else if(a[0] < a[1] && isSorted( a+1, n - 1)){
  12.         return true;
  13.    }
  14.     else {  
  15.        return false;
  16.     }
  17. }
  18. int main() {
  19.     int n;
  20.     cin>>n;
  21.     //vector <int> a(n);
  22.     int a[n];
  23.     char temp;
  24.     int i = 0;
  25.     do{
  26.         cin>>a[i]>>temp;
  27.         i++;
  28.     } while(temp !=  '\n');
  29.     if(isSorted(a, n)){
  30.         cout<<"true";
  31.     }
  32.     else{
  33.         cout<<"false";
  34.     }
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment