uva 465 - Overflow
生活随笔
收集整理的這篇文章主要介紹了
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/archive/2012/05/29/2522900.html
總結
以上是生活随笔為你收集整理的uva 465 - Overflow的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用route命令解决一机双网访问
- 下一篇: 微博营销不可不知的微博六种人