Word Amalgamation(hdoj1113)
Word Amalgamation
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.
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int cmp(int n,char *p,char *q)
{
sort(p,p+n);
sort(q,q+n);
if(==strcmp(p,q))
return ;
else
return ;
}
int main()
{
char a[][],b[][],c[][],i=,j,count1,count2;
bool flags=;
// freopen("in.txt","r",stdin);
while(gets(a[i]))
{
if(!strcmp(a[i],"XXXXXX"))
break;
else
i++;
}
count1=i,i=;/*个数*/
while(gets(b[i]))
{
if(!strcmp(b[i],"XXXXXX"))
break;
else
i++;
}
count2=i;
for(i=;i<count2;i++)
{
int k=;
int lenb=strlen(b[i]);
char bb[];
strcpy(bb,b[i]);
for(j=;j<count1;j++)
{
int lena=strlen(a[j]);
char aa[];
strcpy(aa,a[j]);
if((lena==lenb)&&cmp(lena,bb,aa))
{
strcpy(c[k],a[j]);
k++;
flags=;
}
}
char uu[];
int p;
for(j=;j<k-;j++)
for(p=j+;p<k;p++)
{
if(strcmp(c[j],c[p])>=)
{
strcpy(uu,c[j]);
strcpy(c[j],c[p]);
strcpy(c[p],uu);
}
}
for(j=;j<k;j++)
cout<<c[j]<<endl;
if(flags)
cout<<"******"<<endl;
else
cout<<"NOT A VALID WORD"<<endl<<"******"<<endl;
flags=;
}
}
Word Amalgamation(hdoj1113)的更多相关文章
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- hdu Word Amalgamation(map)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113 找单词 #include <iostream> #include <strin ...
- Java 操作Word书签(二):添加文本、图片、表格到书签内容
在Java操作Word书签(一)中介绍了给Word中的特定段落或文字添加书签.读取及删除已有书签的方法,本文将继续介绍Java 操作Word书签的方法,即如何给已有的书签添加内容,包括添加文本.图片. ...
- hdu1113 Word Amalgamation(详解--map和string的运用)
版权声明:本文为博主原创文章.未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/35338617 转载请注明出 ...
- hdu-----(1113)Word Amalgamation(字符串排序)
Word Amalgamation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- java使用POI操作XWPFDocument 生成Word实战(一)
注:我使用的word 2016功能简介:(1)使用jsoup解析html得到我用来生成word的文本(这个你们可以忽略)(2)生成word.设置页边距.设置页脚(页码),设置页码(文本) 一.解析ht ...
- c# 操作Word总结(车)
在医疗管理系统中为保存患者的体检和治疗记录,方便以后的医生或其他人查看.当把数据保存到数据库中,需要新建很多的字段,而且操作很繁琐,于是想到网页的信息创建到一个word文本中,在显示的时,可以在线打开 ...
- English trip Spoken English & Word List(updating...)
Word List 词汇 Square 英 [skweə] 美 [skwɛr] adj. 平方的:正方形的:直角的:正直的. 使成方形:与…一致 vi. 一致:成方形 n. 平方:广场:正方形 ...
- 用python解析word文件(三):style
太长了,我决定还是拆开三篇写. (一)段落篇(paragraph) (二)表格篇(table) (三)样式篇(style)(本篇) 选你所需即可.下面开始正文. 在前两篇中,我们已经解析出了par ...
随机推荐
- sublime快捷键收藏
快速查找(ctrl + P)输入@+函数名可以快速找到函数.输入#+文本可以快速进行文件内文本匹配.3. 多行游标功能(ctrl + D,非常实用)如何将文件中的某个单词更改为另一个?方法一:利用查找 ...
- 像asp.net Mvc一样开发nodejs+express Mvc站点
像asp.net Mvc一样开发nodejs+express Mvc站点 首先,我是个c#码农.从事Mvc开发已然4个年头了,这两年前端MVC的兴起,我也跟风学了一些,对前端的框架也了解一些,angu ...
- linux下休眠/待机命令
http://blog.csdn.net/hshl1214/article/details/6228275
- 互斥体与互锁 <第五篇>
互斥体实现了“互相排斥”(mutual exclusion)同步的简单形式(所以名为互斥体(mutex)).互斥体禁止多个线程同时进入受保护的代码“临界区”.因此,在任意时刻,只有一个线程被允许进入这 ...
- Unix/Linux环境C编程入门教程(33) 命令和鼠标管理用户和组
Linux是一个多用户.多任务的实时操作系统,允许多人同时访问计算机, 并同时运行多个任务.UNIX系统具有稳定.高效.安全.方便.功能强大等诸多优点,自20世纪70年代开始便运行在许多大型和小型计算 ...
- EasyUI的下拉选择框控件方法被屏蔽处理方式
1.html标签如下 <div id="selectMap" style="top: 1px;left: 80px;position: absolute;" ...
- Word Ladder 解答
Question Given two words (beginWord and endWord), and a dictionary's word list, find the length of s ...
- Kth Smallest Element in Unsorted Array
(referrence: GeeksforGeeks, Kth Largest Element in Array) This is a common algorithm problem appeari ...
- 剑指offer-面试题14.调整数组顺序使奇数位于偶数的前面
题目:输入一个整数数组,实现一个函数来调整该数组中的数字的顺序, 使得所有的奇数位于数组的前半部门,所有的偶数位于数组的后半部门. 这一题一看其实是很简单的,当然在不考虑效率的情况可以这样考虑 我们将 ...
- Linux中查看是否是固态硬盘(SSD)
最近在准备测试,需要看看哪些机器挂载的是ssd硬盘,Google了一圈看到了许多方法,但都云里雾里的,不知道怎么确定.ssd硬盘貌似使用的也是scsi接口,所以根据盘符的名称也是判断不出来的.最 ...