-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersion checker.cpp
76 lines (69 loc) · 1.53 KB
/
Version checker.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//Driver code
int main()
{
string str1, str2;
bool flag = true;
cin >> str1 >> str2;
while(flag){
int t =0;
vector<int> v1, v2;
for(int i=0; i<str1.size(); i++){
if(str1[i] != '.'){
t += str1[i] - '0';
}
else{
v1.push_back(t);
t=0;
}
}
if(str1[str1.size()-1] != '.'){
v1.push_back(t);
t=0;
}
for(int i=0; i<str2.size(); i++){
if(str2[i] != '.'){
t += str2[i] - '0';
}
else{
v2.push_back(t);
t=0;
}
}
if(str2[str2.size()-1] != '.'){
v2.push_back(t);
t=0;
}
bool got = true;
for(int i=0; i<v1.size(); i++){
int t1 = v1[i];
int t2 = 0;
if(i<v2.size()){
t2 = v2[i];
}
if(t1>t2){
cout << str1 << endl;
got = false;
break;
}
else if(t1<t2){
cout << str2 << endl;
got = false;
break;
}
}
if(got){
if(v1.size()>v2.size()){
cout << str1 << endl;
}
else {
cout << str2 << endl;
}
}
flag = false;
}
return 0;
}