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 ...
随机推荐
- CentOS 7一些常用配置
一.更改启动模式 背景:个人开发环境,安装了GNOME桌面,默认启动是图形化模式. 修改为命令行模式. systemctl set-default multi-user.target 二.命令行模式下 ...
- FreeSWITCH第三方库(音频)的简单介绍(一)
FreeSWITCH使用了大量的第三方库,本文档主要介绍音频相关库的信息: 视频相关库的信息介绍参考:http://www.cnblogs.com/yoyotl/p/5488890.html 其他相关 ...
- C# WPF – 利用“Attached Property” 把 RoutedEvent 接上 ICommand
本文说明怎样把 DoubleClick 连接至 ICommand.方法很多.推荐使用 Attach Property 方式,因为它能把任何 RoutedEvent 接上任何 ICommand. 之前写 ...
- 经典JSP数据库连接(ORACLE、SQL Server、MySQL)
1.连接ORACLE8/8I/9I数据库(thin模式) <%@ page language="java" import="java.util.*" pa ...
- firefox 安装flash插件
第一步下载并解压flash解压出一个文件:libflashplayer.so 和文件夹usr 第二步查找plugins其他程序或许也有这个文件夹所以先查找firefox在查找mozilla看在哪个文件 ...
- C#正则表达式编程(四):正则表达式
正则表达式提供了功能强大.灵活而又高效的方法来处理文本.正则表达式的全面模式匹配表示法使您可以快速分析大量文本以找到特定的字符模式:提取.编辑.替换或删除文本子字符串:或将提取的字符串添加到集合以生成 ...
- Android中的文件权限操作
默认本工程创建的文件本工程对其有读写权限. 我们可以通过context.openFileOutput("文件名", 模式): 我们可以创建私有, 共有, 只读, 只写文件, 默认的 ...
- [转载] HTTP 协议漫谈
原文: http://blog.jobbole.com/88199/ 简介 网络上已经有不少介绍HTTP的的好文章.对HTTP的一些细节介绍的比较好,所以本篇文章不会对HTTP的细节进行深究,而是从够 ...
- 学习日记day9: PC端页面流程优化
<!DOCTYPE html><html lang="en"><head> <meta charset="gb2312" ...
- 【浏览器渲染原理】渲染树构建之渲染树和DOM树的关系(转载 学习中。。。)
在DOM树构建的同时,浏览器会构建渲染树(render tree).渲染树的节点(渲染器),在Gecko中称为frame,而在webkit中称为renderer.渲染器是在文档解析和创建DOM节点后创 ...