forked from srikanthmalipatel/Spoj-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ABSYS-3390559-src.c
62 lines (61 loc) · 1.27 KB
/
ABSYS-3390559-src.c
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
#include<stdio.h>
#define MAX 35000
int main()
{
int i,t,j,num1,num2,num3;
char s1[MAX];
char s2[MAX];
char s3[MAX];
char sp1,sp2,sp3,sp4,p,e;
scanf("%d",&t);
for(i = 1; i <= t; i++)
{
num1 = 0;
num2 = 0;
num3 = 0;
scanf("%s%c%c%c%s%c%c%c%s",&s1,&sp1,&p,&sp2,s2,&sp3,&e,&sp4,s3);
j = 0;
while(s1[j] != '\0' && s1[j] != 'm')
{
num1 = (num1*10) + (s1[j] - '0');
j++;
}
if(s1[j] == 'm')
{
num1 = 0;
}
j = 0;
while(s2[j] != '\0' && s2[j] != 'm')
{
num2 = (num2*10) + (s2[j] - '0');
j++;
}
if(s2[j] == 'm')
{
num2 = 0;
}
j = 0;
while(s3[j] != '\0' && s3[j] != 'm')
{
num3 = (num3*10) + (s3[j] - '0');
j++;
}
if(s3[j] == 'm')
{
num3 = 0;
}
if(num1 == 0 || num2 == 0)
{
if(num1 == 0 )
{
num1 = num3 - num2;
}
else
num2 = num3 - num1;
}
else
num3 = num1 + num2;
printf("%d + %d = %d\n",num1,num2,num3);
}
return 0;
}