• <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 閱讀(363) 評論(0)  編輯 收藏 引用

            導航

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

            統計

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品中文无码资源站| 97精品伊人久久大香线蕉| 国产欧美一区二区久久| 国产精品久久久久国产A级| 亚洲国产精品一区二区久久| 久久99精品久久久久久水蜜桃| 久久影院久久香蕉国产线看观看| 超级碰碰碰碰97久久久久| 丁香狠狠色婷婷久久综合| 少妇被又大又粗又爽毛片久久黑人| 久久天天躁夜夜躁狠狠| 久久91亚洲人成电影网站| 国产精品日韩欧美久久综合| 久久人做人爽一区二区三区| 青青青青久久精品国产h| 99久久国产亚洲综合精品| 国产成人精品久久综合| 中文字幕久久精品无码| 久久国产乱子伦精品免费午夜| 久久棈精品久久久久久噜噜| 国产亚州精品女人久久久久久| 亚洲国产精品成人久久| 人人狠狠综合久久亚洲高清| 久久久久四虎国产精品| 亚洲AV无码一区东京热久久| 久久久久亚洲av成人无码电影| 欧美丰满熟妇BBB久久久| 狠狠色丁香婷婷久久综合| 欧美久久精品一级c片片| 精品国产VA久久久久久久冰| 久久婷婷国产剧情内射白浆| 久久夜色撩人精品国产| 国内精品久久久久久久涩爱| 国产欧美久久久精品| 色狠狠久久AV五月综合| 一本久道久久综合狠狠爱| 一本久久免费视频| 思思久久好好热精品国产| 伊人 久久 精品| 亚洲国产成人久久一区久久| 亚洲欧洲精品成人久久奇米网|