Sir plz correct my code
Madam plz correct the code
Madam I check code for input and it is showing correct output for input u have send
your code gives false
answer is true
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for(int i = 0 ; i < n ; i++)
cin >> a[i];
bool check = true;
int i = 0 ;
while(i+1 < n and a[i] > a[i+1]){ // increasing till the sequence is decreasing
i++;
}
while(i+1 < n and a[i] < a[i+1]) // increase till its increasing
i++;
i++;
if(i == n) // if we reach end
cout <<"true"; //return true
else cout <<"false"; // else false
return 0;
}
Thanks madam I can’t get question correctly
the question simply asked u check if they sequence is strictly decreasing then strictly increasing or not
it may be so that the sequence is completly decreasing or completly increasing in those also true is returned
just that decreasing seq should come before increasing
it can neither be dec inc dec