• <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>

            POJ grids 2692

            http://poj.grids.cn/problem?id=2692
            利用枚舉,從'A'到'L'。判斷條件是:如果是'even',則天平兩邊無假幣;如果是'up',若為light,則假幣一定在天平右側,若為heavy,則假幣一定在天平左側;如果是'down',情況相反。
             1 #include<stdio.h>
             2 #include<string.h>
             3 #include<stdlib.h>
             4 char left[3][7],right[3][7],result[3][5];
             5 bool isLight(char c);
             6 bool isheavy(char c);
             7 int main()
             8 {
             9     int n;
            10     while(scanf("%d",&n) != EOF){
            11         while(n--){
            12             for(int i = 0;i < 3;i++)
            13                 scanf("%s%s%s",left[i],right[i],result[i]);
            14             char x;
            15             for(x = 'A';x <= 'L';x++){
            16                 if(isLight(x)){
            17                     printf("%c is the counterfeit coin and it is light.\n",x);
            18                     break;
            19                 }
            20                 if(isheavy(x)){
            21                     printf("%c is the counterfeit coin and it is heavy.\n",x);
            22                     break;
            23                 }
            24             }
            25         }
            26     }
            27     system("pause");
            28     return 0;           
            29 }
            30 
            31 bool isLight(char c)
            32 {
            33     for(int i = 0;i < 3;i++){
            34         if(!strcmp(result[i],"even"))
            35             if(strchr(left[i],c) != NULL || strchr(right[i],c) != NULL)return false;
            36         if(!strcmp(result[i],"up"))
            37             if(strchr(right[i],c) == NULL)return false;
            38         if(!strcmp(result[i],"down"))
            39             if(strchr(left[i],c) == NULL)return false;
            40     }
            41     return true;
            42 }
            43 
            44 bool isheavy(char c)
            45 {
            46     for(int i = 0;i < 3;i++){
            47         if(!strcmp(result[i],"even"))
            48             if(strchr(left[i],c) != NULL || strchr(right[i],c) != NULL)return false;
            49         if(!strcmp(result[i],"up"))
            50             if(strchr(left[i],c) == NULL)return false;
            51         if(!strcmp(result[i],"down"))
            52             if(strchr(right[i],c) == NULL)return false;
            53     }
            54     return true;
            55 }
            56 

            posted on 2009-07-18 14:09 Johnnx 閱讀(364) 評論(0)  編輯 收藏 引用

            導航

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            統計

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            91精品国产乱码久久久久久| 国产精品久久成人影院| 色狠狠久久综合网| 久久精品国产亚洲AV麻豆网站 | 国产成人香蕉久久久久| 亚州日韩精品专区久久久| 久久久久亚洲av无码专区| 久久国产综合精品五月天| 久久青青草原亚洲av无码app| 久久国产综合精品五月天| 999久久久免费精品国产| 日产精品久久久久久久| 久久精品人妻一区二区三区| 青青草原精品99久久精品66| 亚洲国产成人精品91久久久| 大蕉久久伊人中文字幕| 丰满少妇高潮惨叫久久久| 无码任你躁久久久久久老妇App| 久久九九免费高清视频| 精品久久久久久久久中文字幕| 久久人与动人物a级毛片| 色8激情欧美成人久久综合电| 欧美777精品久久久久网| 国产精品久久亚洲不卡动漫| 久久精品亚洲一区二区三区浴池 | 久久国产精品波多野结衣AV| 久久99国产综合精品免费| 亚洲国产精品无码久久一线| 亚洲精品午夜国产VA久久成人| 久久久久久亚洲精品影院| 国产亚洲成人久久| 亚洲国产精久久久久久久| 久久精品国产亚洲沈樵| 大蕉久久伊人中文字幕| 国产精品免费久久久久久久久| 国产精品九九久久免费视频| 久久激情亚洲精品无码?V| 色综合久久中文字幕综合网| 99久久免费国产精品特黄| 国产毛片欧美毛片久久久| 久久精品国产亚洲av高清漫画 |