标签:style lan ase pac while targe std out ==
///@author Sycamore, ZJNU ///@accepted_on 2017-01-17 #include<iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int x, y, z; char c1, c2; cin >> x >> c1 >> y >> c2 >> z; int ans; if (c1 == ‘*‘) { ans = x * y; switch (c2) { case ‘+‘: ans += z; break; case ‘-‘: ans -= z; break; case ‘*‘: ans *= z; break; case ‘/‘: ans /= z; break; case ‘%‘: ans %= z; break; } } else if (c1 == ‘/‘) { ans = x / y; switch (c2) { case ‘+‘: ans += z; break; case ‘-‘: ans -= z; break; case ‘*‘: ans *= z; break; case ‘/‘: ans /= z; break; case ‘%‘: ans %= z; break; } } else if (c1 == ‘%‘) { ans = x%y; switch (c2) { case ‘+‘: ans += z; break; case ‘-‘: ans -= z; break; case ‘*‘: ans *= z; break; case ‘/‘: ans /= z; break; case ‘%‘: ans %= z; break; } } else if (c2 == ‘*‘) { ans = y * z; if (c1 == ‘+‘) { ans += x; } else ans = x - ans; } else if (c2 == ‘/‘) { ans = y / z; if (c1 == ‘+‘) { ans += x; } else ans = x - ans; } else if (c2 == ‘%‘) { ans = y % z; if (c1 == ‘+‘) { ans += x; } else ans = x - ans; } else { switch (c1) { case ‘+‘: ans = x + y; break; case ‘-‘: ans = x - y; break; case ‘*‘: ans = x*y; break; case ‘/‘: ans = x / y; break; case ‘%‘: ans = x%y; break; } switch (c2) { case ‘+‘: ans += z; break; case ‘-‘: ans -= z; break; case ‘*‘: ans *= z; break; case ‘/‘: ans /= z; break; case ‘%‘: ans %= z; break; } } cout << ans << endl; } return 0; }
标签:style lan ase pac while targe std out ==
原文地址:http://www.cnblogs.com/zjnu/p/7248002.html