• <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的話(huà)結(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)  編輯 收藏 引用 所屬分類(lèi): 題目分類(lèi):數(shù)學(xué)/數(shù)論

            FeedBack:
            # re: UVa 465 Overflow
            2012-01-12 20:16 | as
            www.久久热| 久久99精品国产99久久6| 久久精品国产精品亚洲| 国产亚洲精品自在久久| 亚洲中文字幕久久精品无码APP| 久久本道久久综合伊人| 国产ww久久久久久久久久| 26uuu久久五月天| 国产精品狼人久久久久影院| 91精品国产综合久久香蕉| 999久久久免费国产精品播放| 青青草原综合久久| 亚洲乱亚洲乱淫久久| 品成人欧美大片久久国产欧美| 91久久香蕉国产熟女线看| 丰满少妇人妻久久久久久4| 久久久精品日本一区二区三区| 久久亚洲中文字幕精品一区四 | 久久天天躁狠狠躁夜夜av浪潮| 国产三级观看久久| 久久久久国产一区二区三区| 欧美激情精品久久久久久| 久久99热这里只频精品6| 日韩人妻无码一区二区三区久久 | 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久婷婷色综合一区二区| 狠狠色婷婷久久一区二区| 精品久久久久久无码专区| 精品久久一区二区| 久久久91人妻无码精品蜜桃HD| 人妻系列无码专区久久五月天| 精品国产日韩久久亚洲| 少妇久久久久久久久久| 久久精品视频网| 亚洲色欲久久久久综合网| 久久精品国产亚洲AV无码娇色| 国产2021久久精品| 亚洲精品无码久久千人斩| 老司机国内精品久久久久| 亚洲欧美日韩精品久久亚洲区 | 国产精品欧美久久久久无广告|