-
Notifications
You must be signed in to change notification settings - Fork 0
/
10.cpp
47 lines (32 loc) · 839 Bytes
/
10.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
#include <stack>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main(int argc, char** argv) {
ifstream file;
file.open(argv[1]);
string line;
char a;
int b;
stack<char> list;
while(getline(file, line)){
istringstream iss(line);
while (!list.empty()) list.pop();
while (iss >> a) list.push(a);
b = 0;
int j = 1;
while((list.top() - '0') <= 9 ){
b += (list.top() - '0') * j;
j *= 10;
list.pop();
}
if (b <= list.size()){
for(int i = 1; i < b; i++)
list.pop();
cout << list.top() << '\n';
}
}
return 0;
}