-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlineUp.cpp
More file actions
78 lines (51 loc) · 1.51 KB
/
Copy pathlineUp.cpp
File metadata and controls
78 lines (51 loc) · 1.51 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(false); cin.tie(NULL); // to reduce complexity time
int n;
cin >> n; //num of names
//cin.get(); // consumes the /n. USED WHEN INPUT NAMES AFTER ENTERING DATA SET FOR STRINGS!!
cin.ignore();
vector<string> names; //1st vector
vector <string> copy_names; //2nd vector
//To take in data!!
for(int i=0; i<n; i++){
string player;
cin >> player; //input a string
names.push_back(player); //put player name into "names" vector
}
cout << endl << endl;
// copy the players' names into a 2nd vector called copy_names
// This vector is used to check for incr/decr.
// If vector is decr, the sorting algo will not change the vector. vice versa for incre.
for(int i=0; i<names.size(); i++){
copy_names.push_back(names[i]);
}
//To sort data in increasing order
sort(names.begin(), names.end());
if (names == copy_names){
cout << "INCREASING"<<endl;
}
else{
//To sort data in descending order
sort(names.begin(), names.end(), greater<string>()); //greater function for descending order
if(names == copy_names){
cout << "DECREASING"<<endl;
}
else{
cout <<"NEITHER"<<endl;
}
}
// //print out data
// for(auto v:names){
//
// cout << v <<endl;
// }
//
// //print out data
// for(int j=0; j<n; j++){
//
// cout << names[j] << endl;
// }
return 0;
}