Increasing decreasing sequence

#include
using namespace std;

int main()
{
int t;
cin>>t;

while(t--)
{
	int n,p;
	cin>>n;
	cin>>p;

	if(n<p)
	{
		while(n<p)
		{
			p=n;
			cin>>n;
			if(t==0)
			{
				cout<<"true"<<endl;
			}
			else if(n>p)
				break;
		}
		cout<<"false"<<endl;
	}		

	else if(n>p)
	{
		while(n>p)
		{
			p=n;
			cin>>n;
			if(t==0)
			{
				cout<<"true"<<endl;
			}
			else if(n<p)
				break;
		}
		cout<<"true"<<endl;
	}

}
return 0;

}

CAN I DO IT LIKE THIS…AND WHAT IS THE PROBLEM IN IT?

@dsdishu99
According to the question, the following possibilities may arise after splitting a sequence into two sequences:

-First Sequence is strictly decreasing , 2nd sequence is strictly increasing–> return true
-First Sequence is strictly increasing, 2nd sequence strictly decreases-------> return false
-If one sequence is empty and the other sequence is strictly increasing/decreasing—>return true.

Consider test case:
For input:
6
3
2
1
1
2
3

Now this splits into 2 sequences-- 3 2 1(decreasing) and 1 2 3(increasing)
So Expected Output:
true

Following this, try to implement on your own.
And please do not paste your code directly here. Save it on ide.codingblocks.com and then share its link.

what to do next after putting strictly decreasing condition in the attached code?

In your code, you are not taking the inputs properly. Check the question again.


Refer this implementation. Dry run it with the sample test case.

doesn’t the question asks not to arrays or lists?

source.cpp: In function ‘int main()’: source.cpp:26:36: error: lvalue required as left operand of assignment 26 | else if(n1>n2 and isdecreasing = false) | ^~~~~ please help with the error

Hey @dsdishu99