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 ...
随机推荐
- baidu 快递查询API
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- linux终端下为什么用命令打开软件后,要关闭软件才能继续下一条命令?
用终端打开chromium浏览器(命令:chromium-browser)的时候发现打开浏览器之后无法继续在终端输入命令,只能关闭浏览器或者在终端按下Ctrl+c,此时系统将退出浏览器并可以继续在终端 ...
- [JAVA设计模式]第二部分:创建模式
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- XAF应用开发教程(五)验证模块
数据验证是应用程序开发中使用频率最高的功能模块,本节详细介绍一下XAF中如何使用验证模块. XAF 验证模块内置了下面的一些验证规则: 验证规则类型 说明 RuleCombinationOfPrope ...
- jQuery 中$(this).parent().parent().remove()无效。
在写文章系统的删除功能.需要删除一行数据.在删除的页面,需要jQuery 删除一hang. 局部刷新数据. $(".del").click(function(){ var id = ...
- javascript练习----复选框全选,全不选,反选
第一种方式: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...
- iOS - OC NSTimer 定时器
前言 @interface NSTimer : NSObject 作用 在指定的时间执行指定的任务. 每隔一段时间执行指定的任务. 1.定时器的创建 当定时器创建完(不用 scheduled 的,添加 ...
- hdu3060Area2(任意多边形相交面积)
链接 多边形的面积求解是通过选取一个点(通常为原点或者多边形的第一个点)和其它边组成的三角形的有向面积. 对于两个多边形的相交面积就可以通过把多边形分解为三角形,求出三角形的有向面积递加.三角形为凸多 ...
- Maven clean时候出现异常
首先我使用IDEA创建一个空的project,在这个空的project中创建了一个maven module,然后将这个module打包之后,使用maven clean这个target 的时候报错,如下 ...
- Freemarker 入门示例(zhuan)
http://cuisuqiang.iteye.com/blog/2031768 ************************************ 初步学习freemarker ,先做一个简单 ...