-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2queskk.cpp
More file actions
41 lines (32 loc) · 1.08 KB
/
Copy path2queskk.cpp
File metadata and controls
41 lines (32 loc) · 1.08 KB
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
#include <bits/stdc++.h>
using namespace std;
// Function to check the type of the array
void checkType(int arr[], int n)
{
// If the first two and the last two elements
// of the array are in increasing order
if (arr[0] <= arr[1] && arr[n - 2] <= arr[n - 1])
cout<<"0";
// If the first two and the last two elements
// of the array are in decreasing order
else if (arr[0] >= arr[1] && arr[n - 2] >= arr[n - 1])
cout << "Decreasing";
// If the first two elements of the array are in
// increasing order and the last two elements
// of the array are in decreasing order
else if (arr[0] <= arr[1] && arr[n - 2] >= arr[n - 1])
cout << "Increasing then decreasing";
// If the first two elements of the array are in
// decreasing order and the last two elements
// of the array are in increasing order
else
cout << "Decreasing then increasing";
}
// Driver code
int main()
{
int arr[] = { 1, 2, 3, 4 };
int n = sizeof(arr) / sizeof(arr[0]);
checkType(arr, n);
return 0;
}