B - A±B Problem / AtCoderBeginnerContest#016
#include <iostream> using namespace std; void Solve(int a, int b, int c) { char ch[4]={'?', '+', '-', '!'}; int pos=0; if (a+b==a-b && a+b==c) pos=0; else if (a+b == c) pos=1; else if (a-b == c) pos=2; else pos=3; cout << ch[pos] << endl; } int main(void) { int a, b, c; cin >> a >> b >> c; Solve(a,b,c); return 0; }
問題文の書いてある通り場合分けを行い出力。
〜了〜