-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStacking Cups.cpp
More file actions
50 lines (32 loc) · 1.08 KB
/
Copy pathStacking Cups.cpp
File metadata and controls
50 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
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
cin.get();
//vector <int> digits; //single vector
vector< pair <int,string> > digits; //pair vector
for(int i=0; i<n; i++){
string input;
getline(cin,input);
stringstream check(input); //to break up the words (input)
string output1; // to store 1st word
string output2; // to store 2nd word
check >> output1 >> output2; // breaks the word and store into 2 different outputs
if (!isalpha(output1[0])){ // to check if first output[0] is not alpha
int value = stoi(output1); // first output is a number
digits.push_back(make_pair(value/2,output2));
}
else{
int value = stoi(output2); //second output is a number
digits.push_back(make_pair(value,output1));
}
}
sort(digits.begin(),digits.end());
for(auto v: digits){ //just a copy
cout << v.second << " " << endl; // for vector pair, need to indicate (v.first or v.second)
}
return 0;
}