-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabsys.cpp
More file actions
42 lines (37 loc) · 805 Bytes
/
absys.cpp
File metadata and controls
42 lines (37 loc) · 805 Bytes
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
//http://www.spoj.com/problems/ABSYS/
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main()
{
int t, x, y, z; //Mathematical expression written as x + y = z
//string str1, str2, str3;
char s,str1[100], str2[100], str3[100];
char operator1, operator2;
cin>>t;
while(t--)
{
s = getchar();
cin>>str1>>operator1>>str2>>operator2>>str3;
//cout<<s;
if(strspn("m", str1)) { //strspn(str1, str2) returns the length of the initial portion of str1 which consists of charac of only str2
y = atoi(str2);
z = atoi(str3);
x = z-y;
}
else if(strspn("m", str2)) {
x = atoi(str1);
z = atoi(str3);
y = z-x;
}
else {
x = atoi(str1);
y = atoi(str2);
z = x+y;
}
cout<<x<<" + "<<y<<" = "<<z<<endl;
}
return 0;
}