UVA_ Overflow
这道题考的是 atof 的用法;
atof 把字符串转换成浮点数;
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #define UNIT 10 6 #define MAX 2147483647 7 8 using namespace std; 9 10 char a[1000],b[1000],ch; 11 int main() 12 { 13 //freopen("ACM.txt","r",stdin); 14 while(scanf("%s %c %s", a, &ch, b)!=EOF) 15 { 16 printf("%s %c %s\n",a,ch,b); 17 double x1,x2; 18 x1=atof(a); 19 x2=atof(b); 20 if(x1>MAX) 21 cout<<"first number too big"<<endl; 22 if(x2>MAX) 23 cout<<"second number too big"<<endl; 24 if(ch=='+'&&x1+x2>MAX||ch=='*'&&x1*x2>MAX) 25 cout<<"result too big"<<endl; 26 27 } 28 return 0; 29 }