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

            pku1219 L-I-N-G-O: LINGO 很trick的模擬

            題意:
            題目很長,自己看吧,說幾個注意點:
            1、如果猜的字不合法(長度不等于5或者有小寫字母),則輸出上次猜字的結果。(第一次猜字的結果就是原字符串第一個字+"....")
            2、如果超過5次沒猜出來或者輸入結束,用小寫字母輸出原字符串
            3、如果5次之內猜出,則不處理下面的數據(照常讀入)

            然后測試數據有個bug,第一行有一個空行。。

            代碼:

             1# include <cstdio>
             2# include <cstring>
             3using namespace std;
             4bool illegal(char *str)
             5{
             6    if(strlen(str)>5return true;
             7    for(int i=0;i<5;i++)
             8      if(str[i]<'A'||str[i]>'Z')
             9         return true;
            10    return false;
            11}

            12int main()
            13{
            14    //freopen("ans.txt","w",stdout);
            15    char ori[10];
            16    while(gets(ori))
            17    {
            18        if(!strlen(ori))  continue;
            19        if(!strcmp(ori,"LINGO")) break;
            20        puts("");
            21        int used[26];
            22        memset(used,0,sizeof(used));
            23        for(int i=0;i<5;i++) used[ori[i]-65]++;
            24        char last[10];
            25        strcpy(last,ori);
            26        for(int i=1;i<5;i++) last[i]='.';
            27        puts(last);
            28        bool find=false;
            29        int count=0;
            30        while(true)
            31        {
            32           char res[10],str[128];
            33           res[5]='\0';
            34           gets(str);
            35           if(!strlen(str)) break;
            36           if(!find&&count<5)
            37           {
            38               if(illegal(str)) puts(last);
            39               else
            40               {
            41                   int c[26];
            42                   memcpy(c,used,sizeof(used));
            43                   for(int i=0;i<5;i++)
            44                     if(str[i]==ori[i])
            45                       c[str[i]-65]--,res[i]=str[i];
            46                   for(int i=0;i<5;i++)
            47                     if(str[i]!=ori[i]&&c[str[i]-65]>0)
            48                        c[str[i]-65]--,res[i]=str[i]+32;
            49                     else if(str[i]!=ori[i])
            50                        res[i]='.';
            51                   strcpy(last,res);
            52                   puts(res);
            53                   if(!strcmp(str,ori)) find=true;
            54               }

            55               count++;
            56           }

            57        }

            58        if(!find) 
            59        {
            60           for(int i=0;i<5;i++) ori[i]+=32;
            61           puts(ori);
            62        }

            63    }

            64    return 0;
            65}

            66

            posted on 2011-01-16 15:43 yzhw 閱讀(197) 評論(0)  編輯 收藏 引用 所屬分類: simple problem~

            <2011年1月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            導航

            統計

            公告

            統計系統

            留言簿(1)

            隨筆分類(227)

            文章分類(2)

            OJ

            最新隨筆

            搜索

            積分與排名

            最新評論

            閱讀排行榜

            久久亚洲精精品中文字幕| 伊人久久综在合线亚洲2019| 亚洲乱码精品久久久久.. | 91亚洲国产成人久久精品| 国产精品成人99久久久久 | 久久国产精品国产自线拍免费| 欧美一区二区精品久久| 青青草原综合久久大伊人导航| 久久久久久精品免费看SSS| 国产精品久久久久9999高清| 一本大道久久香蕉成人网| 97久久精品无码一区二区| 久久婷婷色综合一区二区| 久久国产精品77777| 无码8090精品久久一区| 亚洲国产成人久久精品影视| 久久亚洲精品无码aⅴ大香| 国产日韩久久免费影院| 奇米综合四色77777久久| 亚洲AV伊人久久青青草原| 久久免费高清视频| 人妻无码久久一区二区三区免费| 久久久久黑人强伦姧人妻| 久久综合九色综合97_久久久| 中文字幕久久精品无码| 中文字幕无码久久精品青草| 久久国产免费| 久久综合五月丁香久久激情| 国产AV影片久久久久久| 伊人久久精品线影院| 九九99精品久久久久久| 国内精品久久久久影院免费| 亚洲午夜久久久久久久久电影网| 精品久久人人妻人人做精品 | 亚洲欧美成人久久综合中文网| 精品国产91久久久久久久| 久久婷婷五月综合97色| 久久久亚洲欧洲日产国码二区| 一本色综合网久久| 久久久亚洲欧洲日产国码二区| 国产V亚洲V天堂无码久久久|