• <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>
            輸入一個字典(用******結尾),然后再輸入若干單詞。每輸入一個單詞w,你都需要在字典中找出所有可以用w的字母重排后得到的單詞,并按照字典序從小到大的順序在一行中輸出(如果不存在,輸出:(  )輸入單詞之間用空格或空行隔開。注意,字典中的單詞不一定按字典排列。

            樣例輸入:
            tarp given score refund only trap work earn course pepper part
            ******
            resco nfudre aptr sett oresuc
            樣例輸出:
            score
            refund
            part tarp trap
            :(
            course
            代碼:
            #include <iostream>
            #include 
            <algorithm>
            #include 
            <string>
            #include 
            <string.h>

            const int maxn = 1000+10;

            using std :: string;
            using std :: sort;
            using std :: cin;
            using std :: cout;
            using std :: endl;

            int main()
            {

                
            string word[maxn];                      //用string類,方便對字符串排序
                char sorted[maxn][maxn],buf[maxn];
                
            int i = 0;

                
            for( ; ; i++)
                {
                    cin 
            >> word[i];
                    
            if(word[i][0]=='*')     break;       //把字典存入word[]中
                }

                sort(word,word
            +i);                        //先把字典排序

                
            for(int t=0; t<i; t++)
                {
                    strcpy(sorted[t],word[t].c_str());   
            //把字典中的數據存入另一個數組里
                    sort(sorted[t],sorted[t]+strlen(sorted[t]));    //把存儲完的字典中每一個單詞的字母排序
                }

                
            while(~scanf("%s", buf))
                {
                    
            bool found = 0 ;
                    sort(buf,buf
            +strlen(buf));                  //把讀入的字符串按字母排序

                    
            for(int t=0; t < i ; t++)
                    {              
            //從排序后的字典中查找
                        if(!strcmp(buf,sorted[t]))           //如果找到
                        {
                            found 
            = 1;
                            cout 
            << word[t] << " " ;        //輸出原字典中對應的單詞
                        }
                    }
                    
            if(!found)   cout << ":(--->>>Not found";    //如果沒有找到則輸出Not found
                    cout << endl;
                }
                
            return 0;
            }
            posted on 2010-05-26 18:32 Vontroy 閱讀(1430) 評論(0)  編輯 收藏 引用 所屬分類: ACM Experience
            激情五月综合综合久久69| 香港aa三级久久三级| 国产香蕉久久精品综合网| 久久久久久精品免费看SSS| 久久精品国产亚洲AV麻豆网站 | 国产精品18久久久久久vr | 国产成人无码久久久精品一| 久久精品中文字幕久久| 伊人久久一区二区三区无码| 精品国产乱码久久久久久郑州公司| 国产一区二区三区久久精品| 欧美久久一区二区三区| 99久久人妻无码精品系列| 欧美精品丝袜久久久中文字幕 | 日本欧美久久久久免费播放网| 久久久久国产精品| 久久久久久精品久久久久| 99久久精品无码一区二区毛片| 77777亚洲午夜久久多喷| 国产精自产拍久久久久久蜜| 久久久亚洲欧洲日产国码二区 | 伊人久久综在合线亚洲2019| 伊人久久大香线蕉AV色婷婷色| 狠狠精品久久久无码中文字幕 | 国产激情久久久久影院| 午夜天堂精品久久久久| 久久久久亚洲av成人网人人软件| 国产精品成人99久久久久| 久久亚洲欧美日本精品| 国产亚洲欧美精品久久久| 久久午夜无码鲁丝片| 97精品伊人久久久大香线蕉| 伊人久久大香线蕉综合5g| 久久这里的只有是精品23| 久久夜色撩人精品国产| 无码任你躁久久久久久| 久久精品这里只有精99品| 久久久久这里只有精品| 色综合久久88色综合天天 | 久久亚洲国产成人影院| 色狠狠久久综合网|