-
Notifications
You must be signed in to change notification settings - Fork 0
/
1287 - Friendly Int Parser.cpp
60 lines (56 loc) · 1.09 KB
/
1287 - Friendly Int Parser.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int i=0, j,l,l1,p;
char s1[51];
string s;
while(getline(cin,s))
{
i=0;
l1=0;
p=1;
for(j=0; s[j]!='\0'; j++)
{
if(s[j]>47 && s[j]<58)
{
s1[i] = s[j];
i++;
}
else if(s[j]=='o' || s[j]=='O')
{
s1[i] = '0';
i++;
}
else if(s[j]=='l')
{
s1[i] = '1';
i++;
}
else if(s[j] == ' ' || s[j] == ',' )
{
}
else
{
p = 0 ;
break;
}
}
s1[i] = '\0';
long long int k;
k = atoll(s1);
if(p==1)
l1 = strlen(s1);
if(l1!=0)
{
if(k<=2147483647)
cout << k << endl;
else
cout << "error" << endl ;
}
else
{
cout << "error" << endl ;
}
}
}