-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxx.cpp
73 lines (71 loc) · 2.05 KB
/
xx.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
//anti - blots
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
string s;
int n,a,b,c,t,i;
char ch;
scanf("%d",&t);
scanf("%c",&ch);
while(t--)
{
scanf("%c",&ch);
getline(cin,s);
int len=s.size(),flag;
flag=0;
a=b=c=0;
// rewrite the code
for(i=0;i<len&&s[i]!='+';++i)
{
if(s[i]==' ')
++i;
if(s[i]=='m')
{
flag=1;
while(s[i]!='+')
++i;
}
if(s[i]=='+')
break;
a=a*10+s[i]-'0';
}
++i;
for(;i<len&&s[i]!='=';++i)
{
if(s[i]==' ')
++i;
if(s[i]=='m')
{
flag=2;
while(s[i]!='=')
++i;
}
if(s[i]=='=')
break;
b=b*10+s[i]-'0';
}
++i;
for(;i<len;++i)
{
if(s[i]==' ')
++i;
if(s[i]=='m')
{
flag=3;
break;
}
if(i>=len)
break;
c=c*10+s[i]-'0';
}
if(flag==1)
printf("%d + %d = %d\n",c-b,b,c);
else if(flag==2)
printf("%d + %d = %d\n",a,c-a,c);
else printf("%d + %d = %d\n",a,b,a+b);
}
return 0;
}