forked from pranavanurag/SPOJSolutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABSYS.cpp
More file actions
41 lines (36 loc) · 699 Bytes
/
Copy pathABSYS.cpp
File metadata and controls
41 lines (36 loc) · 699 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
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int Value(char word[])
{
int sum = 0;
for (int i = 0; i < strlen(word); ++i)
{
if(isalpha(word[i]))
return -1;
else
sum = sum*10 + int(word[i] - '0');
}
return sum;
}
int main()
{
string Input;
int t;
cin>>t;
cin.ignore();
while(t-- && t >= 0)
{
cin.ignore();
char a[20], b[20], c[20], op;
cin>>a>>op>>b>>op>>c;
if(Value(a) < 0)
cout<<Value(c) - Value(b)<<" + "<<Value(b)<<" = "<<Value(c)<<endl;
else if(Value(b) < 0)
cout<<Value(a)<<" + "<<Value(c) - Value(a)<<" = "<<Value(c)<<endl;
else
cout<<Value(a)<<" + "<<Value(b)<<" = "<<Value(a) + Value(b)<<endl;
}
return 0;
}