• <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)  編輯 收藏 引用

            導航

            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            統計

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            日本精品久久久久影院日本| 精品久久久噜噜噜久久久 | 日韩亚洲欧美久久久www综合网| 国内精品久久久久影院优| 国産精品久久久久久久| 中文无码久久精品| 久久精品国产亚洲Aⅴ蜜臀色欲| 午夜精品久久久久久久| 国产精品免费久久久久电影网| 天天影视色香欲综合久久| 97久久超碰成人精品网站| 中文字幕精品久久久久人妻| 久久香蕉国产线看观看乱码| 亚洲欧美伊人久久综合一区二区| 婷婷综合久久狠狠色99h| 亚洲精品国产美女久久久| 久久996热精品xxxx| 国内精品久久国产大陆| 亚洲人成精品久久久久| 亚洲国产精品综合久久一线| 久久久久久久99精品免费观看| 97精品依人久久久大香线蕉97| 日日狠狠久久偷偷色综合96蜜桃| 热久久这里只有精品| 精品久久久久久无码专区不卡 | 91精品国产综合久久四虎久久无码一级| 欧美精品乱码99久久蜜桃| 四虎影视久久久免费| 久久精品国产只有精品66| 国产激情久久久久影院小草 | 久久久噜噜噜久久中文福利| 漂亮人妻被中出中文字幕久久| 性做久久久久久久久| 久久久久国产精品嫩草影院| 精品久久久久久久久久中文字幕 | 亚洲综合精品香蕉久久网| 色综合久久天天综线观看| 欧美粉嫩小泬久久久久久久| 亚洲午夜精品久久久久久浪潮| 亚洲欧洲久久av| 亚洲AV无码1区2区久久|