分析
这题按照题意模拟即可,要注意的有:单个零,前导零,-0,以及行间末符号等
#include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; ll a,b; int t; char c; ll Read() { c=getchar();ll num=0,p=1; bool q=0; while (c>'9'||c<'0') { if (c=='-'&&p>0) p=-1; else return 2147483648ll; c=getchar(); } if (c=='0'&&p==-1) return 2147483648ll; if (c=='0') q=1; while ('0'<=c&&c<='9') { num=num*10+c-'0'; if (num>2147483648ll) return 2147483648ll; if ('0'>c||'9'<c) return 2147483648ll; c=getchar(); if ('0'<=c&&c<='9'&&q) return 2147483648ll; } if (c!=' '&&c!=' ') return 2147483648ll; return num*p; } int main() { freopen("aplusb.in","r",stdin); freopen("aplusb.out","w",stdout); scanf("%d ",&t); while (t--) { a=Read(); if (a>2147483647ll||a<-2147483648ll||c==' ') { printf("Input Error "); while (c!=' ') c=getchar(); continue; } b=Read(); if (c!=' ') b=2147483648ll; if (b>2147483647ll||b<-2147483648ll) { printf("Input Error "); while (c!=' ') c=getchar(); continue; } printf("%lld ",a+b); } fclose(stdin);fclose(stdout); }