File size: 2,416 Bytes
c4b0eef |
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
#include <cmath>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define MOD 1000000007LL
#define LL long long
#define ULL unsigned long long
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")//print new line
#define REP(n) for(int i=0;i<(n);i++)//repeat n times
#define FOR(a,b) for(int i=(a);i<(b);i++)//end not included
#define FORR(n) for(int i=(n);i>=0;i--)//reverse for
using namespace std;
int main()
{
int t=1;
scanf("%d",&t);
while(t--)
{
char c;
int f1=0,f2=0,f3=0;
int n1=0,n2=0,n3=0;
int p=0;
scanf("\n%c",&c);
while(c!='\n')
{
if(p==0)
{
if(c>=48 && c<=57)
{
n1=n1*10 + (c-48);
}
else
{
p++;
if(c=='m')
f1=1;
while(c!='+')
scanf("%c",&c);
scanf("%c",&c);
}
}
else if(p==1)
{
if(c>=48 && c<=57)
{
n2=n2*10 + (c-48);
}
else
{
p++;
if(c=='m')
f2=1;
while(c!='=')
scanf("%c",&c);
scanf("%c",&c);
}
}
else if(p==2)
{
if(c>=48 && c<=57)
{
n3=n3*10 + (c-48);
}
else
{
p++;
if(c=='m')
f3=1;
}
}
scanf("%c",&c);
}
if(f1==1)
{
printf("%d + %d = %d\n",(n3-n2),n2,n3);
}
else if(f2==1)
{
printf("%d + %d = %d\n",n1,(n3-n1),n3);
}
else if(f3==1)
{
printf("%d + %d = %d\n",n1,n2,(n1+n2));
}
}
return 0;
}
|