hdu-----(1113)Word Amalgamation(字符串排序)
Word Amalgamation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2586 Accepted Submission(s): 1246
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.
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.
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.
given
score
refund
only
trap
work
earn
course
pepper
part
XXXXXX
resco
nfudre
aptr
sett
oresuc
XXXXXX
******
refund
******
part
tarp
trap
******
NOT A VALID WORD
******
course
******
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
char old[];
char ne[];
bool operator <(const node &a)const{
if(strcmp(old,a.old)<) return ;
return ;
}
}str[];
int main(){
int i=;
//freopen("test.in","r",stdin);
while(scanf("%s",&str[i].old)&&str[i].old[]!='X'){
strcpy(str[i].ne,str[i].old);
sort(str[i].ne,str[i].ne+strlen(str[i].ne));
i++;
}
int n=i;
sort(str,str+n);
char ss[];
while(scanf("%s",ss)&&ss[]!='X'){
sort(ss,ss+strlen(ss));
int cnt=;
for(int i=;i<n;i++){
if(strcmp(ss,str[i].ne)==){
printf("%s\n",str[i].old);
cnt++;
}
}
if(!cnt) puts("NOT A VALID WORD");
puts("******");
}
return ;
}
hdu-----(1113)Word Amalgamation(字符串排序)的更多相关文章
- hdu - 1113 Word Amalgamation (stl)
http://acm.hdu.edu.cn/showproblem.php?pid=1113 给定一个字典,然后每次输入一个字符串问字典中是否有单词与给定的字符串的所有字母一样(顺序可以打乱),按字典 ...
- poj1318 Word Amalgamation 字符串排序(qsort)
Word Amalgamation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9794 Accepted: 4701 ...
- hdu 1113 Word Amalgamation 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 题意:输入一个字典,然后再输入若干单词(每行中,1 <= 单词数 <= 100,并且 ...
- HDU 1113 Word Amalgamation (map 容器 + string容器)
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across ...
- hdu 1113 Word Amalgamation
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 字符串简单题: stl水过 如下: #include<algorithm> #inc ...
- ZOJ1181 Word Amalgamation 字符串 排序查找
传送门:ZOJ1181 思路:自身排序来判断两个字符串拥有相同的字符. #include<cstdio> #include<cstdlib> #include<io ...
- HDOJ/HDU 1113 Word Amalgamation(字典顺序~Map)
Problem Description In millions of newspapers across the United States there is a word game called J ...
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- Word Amalgamation(枚举 + 排序)
Word Amalgamation Time Limit: 1 Sec Memory Limit: 64 MB Submit: 373 Solved: 247 Description In mil ...
随机推荐
- linux设置tomcat开机自启动
本文假设jdk环境安装成功,如何安装JDK请参考这个链接: http://www.cnblogs.com/yoyotl/p/5395208.html 1. 下载apache的安装包,例如本例下载了ap ...
- Music Player团队项目(一)
团队成员及分工 团队: Blue 团队共有六人 姓名: 学号后四位: 贡献分: 张 宇(队长) 1152 1+1.8=2.8分 侯贺琦 1 ...
- 【VB6笔记-02】从Command中获取链接参数
Public Sub GetParameters() Dim Para As String Para = Command$() gstrUserID = GetCommandPara(Para, ) ...
- Linux基础01 学会使用命令帮助
Linux基础01 学会使用命令帮助 概述 在linux终端,面对命令不知道怎么用,或不记得命令的拼写及参数时,我们需要求助于系统的帮助文档:linux系统内置的帮助文档很详细,通常能解决我们的问题, ...
- hdu 1023 卡特兰数+高精度
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 2013 Multi-University Training Contest 10
HDU-4698 Counting 题意:给定一个二维平面,其中x取值为1-N,y取值为1-M,现给定K个点,问至少包括K个点中的一个的满足要求的<Xmin, Xmax, Ymin, Ymax& ...
- iOS - UIApplication
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIApplication : UIResponder @available(iOS 2.0, *) public ...
- DZY Loves Chessboard
DescriptionDZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m ...
- js一些问题总结
1.undefined与null与NAN的区别 undefined表示未申明,null表示申明了没定义为空值,NAN表示不是数据类型.
- Oracle的参数文件
参数文件的作用: 它们是在数据库实例启动时候加载的,决定了数据库的物理结构.内存.数据库的限制及系统大量的默认值.数据库的各种物理属性.指定数据库控制文件名和路径等信息,是进行数据库设计和性能调优的重 ...