-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeOfArray.cpp
More file actions
55 lines (41 loc) · 792 Bytes
/
Copy pathTypeOfArray.cpp
File metadata and controls
55 lines (41 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int n,count=0,count1=0,t,temp,v;
cin>>t;
while(t--)
{
int acount=0,dcount=0,max=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]>max)
max=a[i];
}
for(int i=0;i<n-1;i++)
{
if(a[i]<a[i+1])
{
acount++;
}
else if(a[i]>a[i+1])
{
dcount++;
}
}
if(dcount==0)
cout<<max<<' '<<'1';
if(acount==0)
cout<<max<<' '<<'2';
if(dcount!=0 && acount>dcount)
cout<<max<<' '<<'4';
if(acount!=0 && dcount>acount)
cout<<max<<' '<<'3';
}
return 0;
}