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 ...
随机推荐
- 【Python网络编程】多线程聊天软件程序
课程设计的时候制作的多线程聊天软件程序 基于python3.4.3 import socket import pickle import threading import tkinter import ...
- BC 65 ZYB's Premutation (线段树+二分搜索)
题目简述:有一个全排列,一直每个前缀区间的逆序对数,还原这个排列. fi记录逆序对数,pi记录该位置数值,则k=fi-f(i-1)表示前i-1个数比pi大的数的个数,那么只要在剩余元素求出按大小顺序第 ...
- Ext4报错Uncaught Ext.Loader is not enabled
提示: Uncaught Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing requ ...
- USB系列之六:基于DOSUSB的简单U盘驱动程序
首先要说明的是,该驱动程序仅实现了部分块设备的功能,如果作为成品软件使用,会感觉性能比较差,而且有些功能(比如FORMAT)是不能完成的,发表此驱动程序的目的旨在说明USB的编程原理以及DOS下驱动程 ...
- [ASP.NET] 图形验证码破解-以简单图形为例
原文 http://www.dotblogs.com.tw/joysdw12/archive/2013/06/08/captcha-cracked.aspx 前言 这次来讲个比较有趣的主题,就是该如何 ...
- bzoj1650 [Usaco2006 Dec]River Hopscotch 跳石子
Description Every year the cows hold an event featuring a peculiar version of hopscotch that involve ...
- bzoj1632 [Usaco2007 Feb]Lilypad Pond
Description Farmer John 建造了一个美丽的池塘,用于让他的牛们审美和锻炼.这个长方形的池子被分割成了 M 行和 N 列( 1 ≤ M ≤ 30 ; 1 ≤ N ≤ 30 ) 正方 ...
- Binary Tree Level Order Traversal 解答
Question Given a binary tree, return the level order traversal of its nodes' values. (ie, from left ...
- 把程序嵌入网页之ATL编写ActiveX[标准窗口+接受参数]
从VS2010开始ATL ActiveX支持IObjectSafety接口,所以用VS2010来编写,新建一个ATL项目 向导的第一页没什么东西,直接下一步,选项可以根据具体需求调整 点“完成”,切换 ...
- hdu 3681 Prison Break(状态压缩+bfs)
Problem Description Rompire . Now it’s time to escape, but Micheal# needs an optimal plan and he con ...