提交时间:2024-01-23 16:33:23
运行 ID: 125201
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ int a,c,ans = 0; char b; cin>>a>>b>>c; string s = ""; s = (c == 0 && b == '/'?"Divided by zero!":""); s = (b != '+' && b != '-' && b != '*' && b != '/'?"Invalid operator!":s); cout<<s; ans = (s.size() > 0?2147483648LL:(b == '+'?a + c:(b == '-'?a - c:(b == '*'?a * c:(b == '/' && c != 0?a / c:2147483648LL))))); string t = ""; t = (ans == 0?"0":""); while (ans){ t += (char)(ans % 10 + '0'); ans /= 10; } cout<<(t == "2147483648" || s.size() > 0?"":t); return 0; }