• <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
            亚洲欧美成人综合久久久| 狠狠色丁香久久婷婷综合_中 | av午夜福利一片免费看久久| 精品久久久久中文字幕日本| 久久91亚洲人成电影网站| 久久久中文字幕日本| 亚洲色大成网站www久久九| 91久久精品视频| 久久精品无码专区免费东京热| 久久国产综合精品五月天| 99久久99久久精品免费看蜜桃| 四虎亚洲国产成人久久精品| 亚洲va久久久噜噜噜久久狠狠| 99精品久久精品| 伊人久久大香线蕉精品不卡| segui久久国产精品| 97久久精品午夜一区二区| 久久久WWW成人免费精品| 99精品国产在热久久无毒不卡 | 久久久久香蕉视频| 久久综合久久自在自线精品自 | 久久综合中文字幕| 亚洲国产精品无码久久一线| 久久精品国产亚洲精品| 国产精品天天影视久久综合网| 亚洲精品成人网久久久久久| 岛国搬运www久久| 久久久av波多野一区二区| 久久亚洲国产精品成人AV秋霞| 久久精品国产第一区二区| 久久国产乱子伦精品免费强| 久久精品一本到99热免费| 久久精品国产免费观看 | 午夜福利91久久福利| 久久国产精品免费一区| 色天使久久综合网天天| 久久不见久久见免费影院www日本| 青青青青久久精品国产 | 亚洲国产二区三区久久| 一级做a爰片久久毛片16| 成人亚洲欧美久久久久|