HDU1113 Word Amalgamation
Description
Input
Output
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
******
Attention:对若干个字符串进行字典排序,应用结构体数组储存字符串(二维数组会报错),以用函数 sort 进行排序。
Code:
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h> using namespace std; char wd[][],wd_sort[][]; struct w
{
char res[];
}wd_rs[]; bool cmp(struct w a,struct w b)
{
return strcmp(a.res,b.res)<;
}
int main()
{
char wt[];
int len=;
while(scanf("%s",wt)&&strcmp(wt,"XXXXXX"))
{
strcpy(wd[len],wt);
strcpy(wd_sort[len],wd[len]);
len++;
} int k=len;
while(k--)
{
sort(wd_sort[k],wd_sort[k]+strlen(wd_sort[k]));
} char w[];
while(scanf("%s",w)&&strcmp(w,"XXXXXX"))
{
sort(w,w+strlen(w)); int flag=,z=;
k=len;
for(int i=;i<=k;i++)
{
if(strcmp(wd_sort[i],w)==)
{
strcpy(wd_rs[z++].res,wd[i]);
flag=;
}
}
if(!flag)
printf("NOT A VALID WORD\n");
else
{
sort(wd_rs,wd_rs+z,cmp);
for(int i=;i<z;i++)
printf("%s\n",wd_rs[i].res);
}
printf("******\n");
} return ;
}
HDU1113 Word Amalgamation的更多相关文章
- hdu1113 Word Amalgamation(详解--map和string的运用)
版权声明:本文为博主原创文章.未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/35338617 转载请注明出 ...
- Word Amalgamation(枚举 + 排序)
Word Amalgamation Time Limit: 1 Sec Memory Limit: 64 MB Submit: 373 Solved: 247 Description In mil ...
- hdu-----(1113)Word Amalgamation(字符串排序)
Word Amalgamation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- Word Amalgamation(hdoj1113)
Word Amalgamation Problem Description In millions of newspapers across the United States there is a ...
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- poj1318 Word Amalgamation 字符串排序(qsort)
Word Amalgamation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9794 Accepted: 4701 ...
- poj 1318 Word Amalgamation
Word Amalgamation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9968 Accepted: 4774 ...
- Uva 642 - Word Amalgamation sort qsort
Word Amalgamation In millions of newspapers across the United States there is a word game called J ...
- hdu 1113 Word Amalgamation 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 题意:输入一个字典,然后再输入若干单词(每行中,1 <= 单词数 <= 100,并且 ...
随机推荐
- 处理jQuery append加入的元素 绑定事件无效的方法
通过jquery append(或者before.after,一样)新添加进网页的元素,常用的事件不能触发,比如:append了id 为 abc 的元素,那么 $(#abc).click(functi ...
- js___原生js轮播
原生js轮播 作为一名前端工程师,手写轮播图应该是最基本掌握的技能,以下是我自己原生js写的轮播,欢迎指点批评: 首先css代码 a{text-decoration:none;color:#3DBBF ...
- Python模块之ConfigParser - 读写配置文件
Python 标准库的 ConfigParser 模块提供一套 API 来读取和操作配置文件. 配置文件的格式 a) 配置文件中包含一个或多个 section, 每个 section 有自己的 opt ...
- v9手机版文章内容不显示
方法一: 打开PHPCMS v9的/phpcms/templates/default/wap/show.html页面, 将网页中的{$content}替换为:{$rs['content']} 这样wa ...
- 关于MATLAB处理大数据坐标文件2017529
今天我们离成功又近了一步,因为又失败了两次 第一次使用了所有特征,理由:前天的特征使用的是取单个特征测试超过85分的特征,结果出现过拟合现象. 本次使用所有特征是为了和昨天的结果作比较. 结果稍好:比 ...
- java 单链表的实现
package liaobiao;//链表测试public class Node { private int value; private Node next; //存放下一个节点的指针 //构造方法 ...
- jquery元素是否可见(隐藏)
var temp1=$(".view_hidden").is(":visible");//是否可见 var temp2=$(".elem_id&quo ...
- JS组件系列——自己动手扩展BootstrapTable的 冻结列 功能:彻底解决高度问题
前言:一年前,博主分享过一篇关于bootstrapTable组件冻结列的解决方案 JS组件系列——Bootstrap Table 冻结列功能IE浏览器兼容性问题解决方案 ,通过该篇,确实可以实现bo ...
- [leetcode-582-Kill Process]
Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each ...
- Idea调试显示切换数据源的设置
使用IDEA调试时,如果遇到相同方法会在编辑器上提示切换到哪个项目,因为手滑点了Disable,所以导致后来就不提示了,记录下设置方法.