-
Notifications
You must be signed in to change notification settings - Fork 0
/
lineup.cpp
54 lines (45 loc) · 1.13 KB
/
lineup.cpp
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
// Get the number of names
int n;
cin >> n;
// Get the first 2 names
string a, b;
cin >> a >> b;
bool increasing = true; // Whether the names are increasing
bool neither = false; // Whether there is no order
// If the first name is after the second name alphabetically
if(a > b)
{
// Set the names as decreasing
increasing = false;
}
// For the rest of the names
for(int i = 2; i < n; i++)
{
a = b; // Set a as the last seen name
cin >> b; // Get the next name
// If this name is after the previous name and the names should be
// decreasing, or the name is before the previous name and the names
// should be increasing
if(increasing && b < a || (!increasing && a < b))
{
neither = true; // Set that neither is the case
}
}
if(neither)
{
cout << "NEITHER" << endl;
}
else if(increasing)
{
cout << "INCREASING" << endl;
}
else
{
cout << "DECREASING" << endl;
}
return 0;
}