-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathABSYS.cpp
60 lines (53 loc) · 1.02 KB
/
ABSYS.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
/* replacing the 'machula' */
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
//checking whether the part of expression consist of 'machula'
int compar(string s){
int l=s.size()-7;
if(l>=0){ //if its less than 7 then it doesn't contain the 7 letter word 'machula'
int i;
string str="machula";
for(i=0;i<=l;i++)
if(s.compare(i,7,str)==0)
return 1;
}
return 0;
}
//changing the string into number
int change(string s){
int i,n,l=s.size();
n=s[0]-'0';
for(i=1;i<l;i++)
n=(s[i]-'0')+n*10;
return n;
}
int main() {
int t,i,ix,iy,iz;
string x,y,z;
scanf("%d",&t);
for(i=1;i<=t;i++){
cin>>x;
scanf("%*c%*c%*c");
cin>>y;
scanf("%*c%*c%*c");
cin>>z;
if(compar(x)){
iy=change(y);
iz=change(z);
printf("%d + %d = %d\n",iz-iy,iy,iz);
}
else if(compar(y)){
ix=change(x);
iz=change(z);
printf("%d + %d = %d\n",ix,iz-ix,iz);
}
else if(compar(z)){
iy=change(y);
ix=change(x);
printf("%d + %d = %d\n",ix,iy,ix+iy);
}
}
return 0;
}