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

            導航

            <2009年6月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            統計

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久本道伊人久久| 少妇熟女久久综合网色欲| 2021少妇久久久久久久久久| 成人免费网站久久久| 欧美激情精品久久久久久久| 久久久久久久久66精品片| 狠狠久久亚洲欧美专区 | 久久精品无码专区免费青青| 久久福利青草精品资源站| 日本亚洲色大成网站WWW久久| 99久久夜色精品国产网站| 国产精品美女久久久久AV福利| 一本色道久久综合亚洲精品| 国产精品成人99久久久久| 久久天天躁狠狠躁夜夜avapp| 三级韩国一区久久二区综合| 999久久久无码国产精品| 成人综合久久精品色婷婷| 久久无码人妻精品一区二区三区| 国产精品福利一区二区久久| 久久婷婷五月综合国产尤物app| 国产成人久久久精品二区三区| 欧美大香线蕉线伊人久久| 狠狠色丁香久久婷婷综合图片| 精品久久久无码中文字幕天天| 91久久婷婷国产综合精品青草| 日本久久久久亚洲中字幕| 国内高清久久久久久| 久久人人爽人人爽人人片AV麻烦| 日产久久强奸免费的看| 久久精品国产亚洲一区二区三区| 88久久精品无码一区二区毛片 | 色综合久久综精品| 久久人人爽爽爽人久久久| 人妻久久久一区二区三区| 久久久精品人妻一区二区三区四| 麻豆成人久久精品二区三区免费 | 久久青青草原国产精品免费| 国产韩国精品一区二区三区久久| 久久久久久国产精品免费无码 | 亚洲国产精品无码久久SM|