Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- // bool isSorted(vector<int> a, n){
- bool isSorted(int *a, int n){
- if(n== 1){
- return true;
- }
- else if(a[0] < a[1] && isSorted( a+1, n - 1)){
- return true;
- }
- else {
- return false;
- }
- }
- int main() {
- int n;
- cin>>n;
- //vector <int> a(n);
- int a[n];
- char temp;
- int i = 0;
- do{
- cin>>a[i]>>temp;
- i++;
- } while(temp != '\n');
- if(isSorted(a, n)){
- cout<<"true";
- }
- else{
- cout<<"false";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment