-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP12952.cpp
49 lines (47 loc) · 862 Bytes
/
P12952.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
#include <iostream>
#include <ctype.h>
bool readInts(int &a, int &b) {
a = b = 0;
bool aStarted = false;
bool aDone = false;
char w[20];
if(!std::cin.getline(w, 20))
return false;
for(int i = 0; i < 20; ++i) {
if(w[i] == '-') {
if(!aStarted) {
aStarted = true;
}
}
else if(w[i] >= '0' && w[i] <= '9') {
if(aDone)
b = b*10 + (w[i]-'0');
else {
a = a*10 + (w[i]-'0');
aStarted = true;
}
}
else {
if(!isprint(w[i]))
break;
if(aStarted)
aDone = true;
}
}
//std::cerr << "Read " << a << ", " << b << std::endl;
return true;
}
int main() {
int a, b;
while(readInts(a, b)) {
if(a == b) {
std::cout << a << std::endl;
}
else if(a > b) {
std::cout << a << std::endl;
}
else if(a < b) {
std::cout << b << std::endl;
}
}
}