• <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,則假幣一定在天平右側(cè),若為heavy,則假幣一定在天平左側(cè);如果是'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 閱讀(361) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

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

            統(tǒng)計

            常用鏈接

            留言簿(1)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久亚洲中文字幕精品一区| 久久久久国产精品| 国内高清久久久久久| 亚洲精品无码久久一线| 国产精品一久久香蕉国产线看 | 久久只有这精品99| 久久人妻少妇嫩草AV无码专区 | 久久精品天天中文字幕人妻| 热re99久久精品国产99热| 欧美日韩精品久久久免费观看| 亚洲中文久久精品无码| 亚洲一区二区三区日本久久九| 婷婷久久五月天| 国产L精品国产亚洲区久久| 久久综合亚洲欧美成人| 日本加勒比久久精品| 日本免费一区二区久久人人澡| 久久精品中文无码资源站| 欧美久久精品一级c片片| 久久久久久久久波多野高潮| 国产精品青草久久久久福利99| 久久精品亚洲日本波多野结衣| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 亚洲成色WWW久久网站| 欧美日韩成人精品久久久免费看| 久久精品亚洲一区二区三区浴池 | 久久伊人色| 国产精品99久久精品爆乳| 久久精品国产亚洲AV嫖农村妇女| 久久伊人五月丁香狠狠色| 香蕉久久夜色精品国产2020| 久久久中文字幕日本| 久久99热这里只有精品国产 | 色妞色综合久久夜夜| 久久久久久久久66精品片| 无码乱码观看精品久久| 久久久久亚洲AV无码专区网站 | 亚洲va久久久噜噜噜久久天堂| 久久免费看黄a级毛片| 99久久综合国产精品免费| 麻豆精品久久久久久久99蜜桃|