• <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
            需要注意兩點:1、前導0要刪除;2、a或者b溢出,c也不一定溢出,a或b為0的話結果為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 閱讀(599) 評論(1)  編輯 收藏 引用 所屬分類: 題目分類:數學/數論

            FeedBack:
            # re: UVa 465 Overflow
            2012-01-12 20:16 | as
            DSFAS  回復  更多評論
              
            国产精品亚洲综合专区片高清久久久| 久久久精品波多野结衣| 久久久久无码精品国产不卡| 无码人妻精品一区二区三区久久 | 久久狠狠一本精品综合网| 久久午夜福利电影| 人妻少妇久久中文字幕 | 国产一区二区三精品久久久无广告| 人妻精品久久久久中文字幕| 精品久久无码中文字幕| 四虎影视久久久免费观看| 国产精品久久久久久影院| 欧美一区二区久久精品| 国产A级毛片久久久精品毛片| 丁香色欲久久久久久综合网| 久久精品免费网站网| 精品国产91久久久久久久| 国产偷久久久精品专区| 色综合久久天天综线观看| 亚洲国产精品久久久久婷婷软件| 久久久久亚洲AV无码永不| 婷婷国产天堂久久综合五月| 久久国产精品二国产精品| 久久国产精品一区二区| 久久综合精品国产二区无码| 思思久久精品在热线热| 久久亚洲天堂| 日韩中文久久| 色综合久久88色综合天天 | 久久久久这里只有精品| 日日狠狠久久偷偷色综合96蜜桃| 精品国产91久久久久久久a| 久久香蕉国产线看观看99| 国产精品美女久久久久久2018| 无码人妻少妇久久中文字幕蜜桃| 亚洲国产精品无码久久| 久久99久国产麻精品66| 伊人久久大香线蕉av一区| 久久无码人妻一区二区三区 | 久久久91精品国产一区二区三区| 欧美一区二区三区久久综合|