• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            需要注意兩點(diǎn):1、前導(dǎo)0要?jiǎng)h除;2、a或者b溢出,c也不一定溢出,a或b為0的話結(jié)果為0。
            以下是我的代碼:
            #include <iostream>
            #include 
            <sstream>
            #include 
            <string>
            #include 
            <cstdio>
            using namespace std;
            typedef 
            long long int64;

            const string kInf = "2147483647";

            int cmp ( const string &a, const string &b )
            {
                
            if ( a.size() > b.size() )
                    
            return 1;
                
            else if ( a.size() < b.size() )
                    
            return -1;
                
            else
                {
                    
            for ( int i = 0; i < a.size(); i++ )
                        
            if ( a[i] > b[i] )
                            
            return 1;
                        
            else if ( a[i] < b[i] )
                            
            return -1;
                    
            return 0;
                }
            }

            int main ()
            {
            #ifndef ONLINE_JUDGE
                freopen ( 
            "data.in""r", stdin );
            #endif
                
                
            string a, t, b;
                
                
            while ( cin >> a >> t >> b )
                {
                    cout 
            << a << " " << t << " " << b << endl;
                    
            while ( a.size() > 1 && a[0== '0' )
                        a.erase ( 
            01 );
                    
            //cout << a << endl;
                    while ( b.size() > 1 && b[0== '0' )
                        b.erase ( 
            01 );
                    
            //cout << b << endl;
                    bool over = false;
                    
            if ( cmp ( a, kInf ) > 0 )
                    {
                        printf ( 
            "first number too big\n" );
                        over 
            = true;
                    }
                    
            if ( cmp ( b, kInf ) > 0 )
                    {
                        printf ( 
            "second number too big\n" );
                        over 
            = true;
                    }
                    
            if ( over )
                    {
                        
            if ( t == "+" || ( t == "*" && a != "0" && b != "0" ) ) 
                            printf ( 
            "result too big\n" );
                        
            continue;
                    }
                    int64 aa, bb, cc;
                    istringstream ( a ) 
            >> aa;
                    istringstream ( b ) 
            >> bb;
                    
            if ( t == "+" )
                        cc 
            = aa + bb;
                    
            else
                        cc 
            = aa * bb;
                    
            if ( cc > 0x7fffffff )
                        printf ( 
            "result too big\n" );
                }
                
                
            return 0;
            }
            posted on 2011-09-08 10:42 lee1r 閱讀(578) 評(píng)論(1)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)學(xué)/數(shù)論

            FeedBack:
            # re: UVa 465 Overflow
            2012-01-12 20:16 | as
            99热热久久这里只有精品68| 久久久久亚洲AV成人网人人网站| 亚洲欧美国产日韩综合久久| 日本精品久久久久中文字幕| 精品国产乱码久久久久久1区2区| 久久国产色av免费看| 久久婷婷五月综合成人D啪| 伊人色综合久久天天人守人婷| 久久青青草原精品国产软件| 一本大道久久香蕉成人网| 一本大道久久东京热无码AV| 热久久视久久精品18| 日韩av无码久久精品免费| 2022年国产精品久久久久 | 久久综合亚洲欧美成人| 伊人 久久 精品| 久久精品无码一区二区WWW| 久久久噜噜噜久久中文字幕色伊伊 | 伊人久久综合精品无码AV专区| 99精品久久精品一区二区| 久久久婷婷五月亚洲97号色| 色综合色天天久久婷婷基地| 久久精品国产亚洲AV不卡| 久久99国产精品久久99小说 | 青青草国产精品久久| 狠狠色综合久久久久尤物| 亚洲欧美日韩精品久久亚洲区 | 99久久精品免费国产大片| 欧美性大战久久久久久| 久久婷婷五月综合色奶水99啪| 国产精品国色综合久久| 日本精品久久久久影院日本 | 久久久久国产一级毛片高清板| 久久无码AV一区二区三区| www亚洲欲色成人久久精品| 精品久久久无码21p发布| 国产一区二区精品久久岳| 午夜不卡久久精品无码免费| 久久国产福利免费| 久久午夜伦鲁片免费无码| 久久亚洲精品国产亚洲老地址|