设为首页 加入收藏

TOP

UVA 465-- Overflow (atof 函数)
2015-07-20 17:57:16 来源: 作者: 【 】 浏览:5
Tags:UVA 465-- Overflow atof 函数

Overflow

Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be represented as a ``normal'' signed integer (type integer if you are working Pascal, type int if you are working in C).

Input

An unspecified number of lines. Each line will contain an integer, one of the two operators + or *, and another integer.

Output

For each line of input, print the input followed by 0-3 lines containing as many of these three messages as are appropriate: ``first number too big'', ``second number too big'', ``result too big''.

Sample Input

300 + 3
9999999999999999999999 + 11

Sample Output

300 + 3
9999999999999999999999 + 11
first number too big
result too big
 
 
本来是道模拟题,wa了7次没过去 无奈直接上atof函数了 ,此函数将输入的字符串转化为浮点型(double)
 
 
#include
   
    
#include 
    
      #include 
     
       #include 
      
        using namespace std; const int MAX=2147483647; int main() { char op,a[1100],b[1100]; while(cin>>a>>op>>b) { cout<
       
        MAX) cout<<"first number too big"<
        
         MAX) cout<<"second number too big"<
         
          MAX) cout<<"result too big"<
          
           MAX) cout<<"result too big"<
           
            

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ2352_Stars(线段树/单点更新) 下一篇nyist oj 115 城市平乱 (最短路径..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: