日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

杭电1113--Word Amalgamation

發布時間:2023/12/15 综合教程 60 生活家
生活随笔 收集整理的這篇文章主要介紹了 杭电1113--Word Amalgamation 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Word Amalgamation

Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2845Accepted Submission(s): 1369

Problem Description
In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the answer it is necessary to unscramble four words. Your task is to write a program that can unscramble words.

Input
The input contains four parts:

1. a dictionary, which consists of at least one and at most 100 words, one per line;
2. a line containing XXXXXX, which signals the end of the dictionary;
3. one or more scrambled `words' that you must unscramble, each on a line by itself; and
4. another line containing XXXXXX, which signals the end of the file.

All words, including both dictionary words and scrambled words, consist only of lowercase English letters and will be at least one and at most six characters long. (Note that the sentinel XXXXXX contains uppercase X's.) The dictionary is not necessarily in sorted order, but each word in the dictionary is unique.

Output
For each scrambled word in the input, output an alphabetical list of all dictionary words that can be formed by rearranging the letters in the scrambled word. Each word in this list must appear on a line by itself. If the list is empty (because no dictionary words can be formed), output the line ``NOT A VALID WORD" instead. In either case, output a line containing six asterisks to signal the end of the list.

Sample Input

tarp
given
score
refund
only
trap
work
earn
course
pepper
part
XXXXXX
resco
nfudre
aptr
sett
oresuc
XXXXXX

Sample Output

score
******
refund
******
part
tarp
trap
******
NOT A VALID WORD
******
course
******

Source
Mid-Central USA 1998

Recommend
Eddy|We have carefully selected several similar problems for you:10731075103910621088
<1>輸入幾個字符串,(按字典序排好)→ 用作字典;
<2>輸入無序單詞,查找;
<3>輸出;

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 struct dic
 7 {
 8     int n ;
 9     char str[10]; 
10 };
11 dic num[110];
12 
13 bool cmp(char c, char b)
14 {
15     return c > b; 
16 }
17 
18 bool cpm(dic str, dic n)
19 {
20     return strcmp(str.str, n.str) < 0;
21 }
22 int main()
23 {
24     char ch[10];
25     char s[10];
26     char ac[110][10];
27     int i, j,total=0;
28     while(~scanf("%s",ch)&&strcmp(ch, "XXXXXX")!=0)
29     {
30         strcpy(num[total++].str, ch);
31         //i++;
32     }    
33     sort(num, num+total, cpm);
34     //printf("%d
", total);
35     while(~scanf("%s",ch),strcmp(ch, "XXXXXX")!=0)
36     {
37         int flag=0 ,len;
38         int nel=strlen(ch);
39         sort(ch, ch+nel, cmp);
40         for(i=0; i<=total; i++)
41         {
42                strcpy(s, num[i].str);
43             len = strlen(s);
44             sort(s, s+len, cmp);
45             if(strcmp(s, ch) == 0)
46             {
47                 printf("%s
", num[i].str);
48                 flag++;
49             }
50             //else
51             //printf("NOT A VALID WORD
");
52         }
53         if(flag==0)
54         printf("NOT A VALID WORD
");
55           /*else
56         {
57             sort(ac,ac+flag,cpm);
58             for(i=0; i<flag; i++)
59             printf("%s", ac[i]);
60         }*/
61         printf("******
");
62     }
63     return 0;
64 }

總結

以上是生活随笔為你收集整理的杭电1113--Word Amalgamation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。