• <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
            從string中尋找"P="、"U="、"I=",然后記錄P、U、I的值,使用istringstream比較方便。
            以下是我的代碼:
            #include<iostream>
            #include
            <sstream>
            #include
            <string>
            #include
            <cstdio>
            using namespace std;

            int main()
            {
                
            /*
                freopen("data.in","r",stdin);
                freopen("data.out","w",stdout);
                //
            */

                
            int T;
                cin
            >>T;getchar();
                
            for(int case_num=1;case_num<=T;case_num++)
                {
                    
            string line;
                    getline(cin,line);
                    
            double P(-1.0),U(-1.0),I(-1.0);
                    istringstream sin(line);
                    
            char ch;
                    
            while(sin>>ch)
                    {
                        
            if(ch=='P')
                        {
                            
            char t;
                            sin
            >>t;
                            
            if(t!='=')
                                
            continue;
                            sin
            >>P;
                            sin
            >>t;
                            
            if(t=='m')
                                P
            /=1000;
                            
            else if(t=='k')
                                P
            *=1000;
                            
            else if(t=='M')
                                P
            *=1000000;
                        }
                        
            else if(ch=='U')
                        {
                            
            char t;
                            sin
            >>t;
                            
            if(t!='=')
                                
            continue;
                            sin
            >>U;
                            sin
            >>t;
                            
            if(t=='m')
                                U
            /=1000;
                            
            else if(t=='k')
                                U
            *=1000;
                            
            else if(t=='M')
                                U
            *=1000000;
                        }
                        
            else if(ch=='I')
                        {
                            
            char t;
                            sin
            >>t;
                            
            if(t!='=')
                                
            continue;
                            sin
            >>I;
                            sin
            >>t;
                            
            if(t=='m')
                                I
            /=1000;
                            
            else if(t=='k')
                                I
            *=1000;
                            
            else if(t=='M')
                                I
            *=1000000;
                        }
                    }

                    cout
            <<"Problem #"<<case_num<<endl;
                    
            if(P==-1.0)
                        printf(
            "P=%.2fW\n",U*I);
                    
            else if(U==-1.0)
                        printf(
            "U=%.2fV\n",P/I);
                    
            else
                        printf(
            "I=%.2fA\n",P/U);
                    printf(
            "\n");
                }

                
            return 0;
            }
            posted on 2011-04-07 12:53 lee1r 閱讀(715) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:字符串處理
            秋霞久久国产精品电影院| 久久国产精品一区| 久久这里只有精品视频99| 97久久天天综合色天天综合色hd| 欧美精品国产综合久久| 久久久久综合国产欧美一区二区| 国产精品内射久久久久欢欢 | 秋霞久久国产精品电影院| 国产国产成人精品久久| jizzjizz国产精品久久| 99久久精品毛片免费播放| 韩国无遮挡三级久久| 老司机国内精品久久久久| 97超级碰碰碰碰久久久久| 久久精品国产一区二区三区 | 狠狠久久综合| 色诱久久av| 97久久国产露脸精品国产| 一本色综合网久久| 久久超乳爆乳中文字幕| 亚洲国产精品久久66| 亚洲精品97久久中文字幕无码| 精品国产日韩久久亚洲| 精品久久人妻av中文字幕| 国产精品免费久久久久久久久| 波多野结衣久久精品| 99久久久精品| 99精品久久精品一区二区| 久久r热这里有精品视频| 欧美麻豆久久久久久中文| 日韩精品久久久久久久电影蜜臀| 亚洲天堂久久精品| 久久午夜无码鲁丝片秋霞| 日本免费久久久久久久网站| 久久久久久亚洲精品影院| 久久这里只有精品久久| 一本色道久久综合亚洲精品| 久久久久亚洲av成人无码电影| 久久精品国产亚洲AV久| 久久国产精品无码网站| 99久久免费国产特黄|