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,并且 ...
随机推荐
- Mac 上Python多版本切换
Mac上自带了Python2.x的版本,有时需要使用Python3.x版本做开发,但不能删了Python2.x,可能引起系统不稳定,那么就需要安装多个版本的Python. 1.安装Python3.x版 ...
- mysql关闭/启用外键约束
1.有时为了导入数据方便,需要临时关闭外键约束mysql>SET FOREIGN_KEY_CHECKS=0; 2.打开外键约束mysql>SET FOREIGN_KEY_CHECKS=1; ...
- flask 扩展之 -- flask-pagedown
支持 Markdown 语法, 并添加 富文本文章的预览功能. 使用到的包列表: PageDown : 使用 JavaScript 实现的客户端 Markdown 到 HTML 的转换程序. Flas ...
- PHPCMS V9 导航栏当前栏目高亮
实际上这个东西可有可无,很多站点看似导航栏当鼠标指向后都会变化等高亮处理,一般都比较醒目,但是实质点击过去后,都还是只是刚才的样式,因为这些站点的导航栏都没有对当前选中栏目做CSS的指定变化处理. 该 ...
- java架构师负载均衡、高并发、nginx优化、tomcat集群、异步性能优化、Dubbo分布式、Redis持久化、ActiveMQ中间件、Netty互联网、spring大型分布式项目实战视频教程百度网盘
15套Java架构师详情 * { font-family: "Microsoft YaHei" !important } h1 { background-color: #006; ...
- vue1与vue2的路由 以及vue2项目大概了解
vue1的路由 1.设置根组件 Vue.extend() 2.设置局部组件 Vue.extend({template:"/home"}) 3.实例化路由 var route ...
- 【数据结构与算法】一致性Hash算法及Java实践
追求极致才能突破极限 一.案例背景 1.1 系统简介 首先看一下系统架构,方便解释: 页面给用户展示的功能就是,可以查看任何一台机器的某些属性(以下简称系统信息). 消息流程是,页面发起请求查看指定机 ...
- c# 读写文件时文件正由另一进程使用,因此该进程无法访问该文件
c# 读写文件时文件正由另一进程使用,因此该进程无法访问该文件,在IO处理上遇到了无法操作的问题. 文件"D:\log.txt"正由另一进程使用,因此该进程无法访问该文件. log ...
- 【LeetCode】87. Scramble String
题目: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty subs ...
- 【Android Developers Training】 56. 更效率地加载大图片
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...