uva 465 Overflow

这道题没有什么难得,就是一些常识不太清楚,这是从一位学长那看来的,觉得很简单

View Code
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5     char str1[1001],str2[1001],c;
 6     double a,b;
 7     while(scanf("%s %c %s",str1,&c,str2)!=EOF)
 8     {
 9         a=atof(str1);
10         b=atof(str2);
11         printf("%s %c %s\n",str1,c,str2);
12         if(a>2147483647)
13         printf("first number too big\n");
14         if(b>2147483647)
15         printf("second number too big\n");
16         if(c=='+')
17         {
18             if(a+b>2147483647)
19             printf("result too big\n");
20         }
21         if(c=='*')
22         {
23             if(a*b>2147483647)
24             printf("result too big\n");
25         }
26     }
27     return 0;
28 }

总结:

1、int 的值是2147483647

2、atof()函数:将字符串转化成浮点数double型

   atoi()函数:把字符串转换成整型数

   atol()函数:把字符串转换成长整型

   strtod()函数:将字符串转换成浮点数。

原文地址:https://www.cnblogs.com/wanglin2011/p/2522900.html