• <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 閱讀(705) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:字符串處理
            久久亚洲国产精品五月天婷| 性欧美大战久久久久久久久 | 久久国产高清字幕中文| 99久久777色| 久久露脸国产精品| 久久国产精品99国产精| 久久AⅤ人妻少妇嫩草影院| 99久久国产宗和精品1上映| 久久ww精品w免费人成| 久久久久九九精品影院| 久久狠狠高潮亚洲精品 | 精品国产乱码久久久久久呢| 日本精品久久久久中文字幕| 热久久视久久精品18| 国产精品99久久精品爆乳| 久久精品极品盛宴观看| 国产激情久久久久影院| 久久Av无码精品人妻系列| 伊人久久成人成综合网222| 91精品国产色综久久| 久久久久99精品成人片欧美| 热久久最新网站获取| 久久丝袜精品中文字幕| 久久精品国产91久久综合麻豆自制| 久久综合亚洲色HEZYO社区| 久久人妻少妇嫩草AV无码蜜桃| 国产69精品久久久久777| 久久久噜噜噜久久熟女AA片| av色综合久久天堂av色综合在| 久久黄视频| 久久亚洲AV无码西西人体| 久久久精品久久久久特色影视 | 婷婷久久综合| 久久91精品国产91| 一本色道久久综合狠狠躁| 东方aⅴ免费观看久久av| 伊人久久无码中文字幕| 无码AV中文字幕久久专区| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 久久综合久久伊人| 久久996热精品xxxx|