File size: 1,559 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
/*
****************************************************************
****************************************************************
-> Coded by Stavros Chryselis
-> Visit my github for more solved problems over multiple sites
-> https://github.com/StavrosChryselis
-> Feel free to email me at [email protected]
****************************************************************
****************************************************************
*/
#include <stdio.h>
#include <string>
#include <ctype.h>
#define gc() getchar_unlocked()
using namespace std;
inline int first()
{
string A;
char c;
c = gc();
while(isspace(c))
c = gc();
while(c!=' ')
{
if(isalpha(c))
{
while(c!=' ')
c = gc();
return -1;
}
A.push_back(c);
c = gc();
}
return stoi(A);
}
inline int second()
{
string A;
char c;
gc();
gc();
c = gc();
while(c!=' ')
{
if(isalpha(c))
{
while(c!=' ')
c = gc();
return -1;
}
A.push_back(c);
c = gc();
}
return stoi(A);
}
inline int third()
{
string A;
char c;
gc();
gc();
c = gc();
while(c!='\n' && c!=EOF)
{
if(isalpha(c))
{
while(c!='\n' && c!=EOF)
c = gc();
return -1;
}
A.push_back(c);
c = gc();
}
return stoi(A);
}
int main()
{
int T;
int f, s, t;
//freopen("input.txt","r",stdin);
scanf("%d", &T);
while(T--)
{
f = first();
s = second();
t = third();
if(f == -1)
f = t - s;
if(s == -1)
s = t - f;
if(t == -1)
t = f + s;
printf("%d + %d = %d\n", f, s, t);
}
return 0;
}
|