题目地址:点击打开链接
C++代码:
#include <cstdlib> #include <cstdio> int main() { char s1[10000],s2[10000]; double a,b,ans; char c; while(scanf("%s %c %s",s1,&c,s2)!=EOF) { a=atof(s1); b=atof(s2); printf("%s %c %s ",s1,c,s2); if(a>2147483647) printf("first number too big "); if(b>2147483647) printf("second number too big "); if(c=='+') ans=a+b; else ans=a*b; if(ans>2147483647) printf("result too big "); } return 0; }