Word Amalgamation(枚举 + 排序)
Word Amalgamation
Time Limit: 1 Sec Memory Limit: 64 MB Submit: 373 Solved: 247
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
******
HINT
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[][] ;
char b[][] ; void Sort (int n)
{
for (int i = ; i < n; i++) {
if (strcmp (a[i] , a[i - ]) < ) {
char ans[] ;
strcpy (ans , a[i] ) ;
int j ;
for (j = i - ; j >= && strcmp (ans , a[j]) < ; j--) {
strcpy (a[j + ] , a[j] ) ;
}
strcpy (a[j + ] , ans ) ;
}
}
} int main ()
{
//freopen ("a.txt" , "r" , stdin ) ;
int n = , s ;
do {
gets (a[n++]) ;
} while (strcmp (a[n - ] , "XXXXXX") != ) ;
n-- ;
Sort (n) ;
int k = ;
do {
gets (b[k++]) ;
} while (strcmp (b[k - ] , "XXXXXX") != ) ;
k-- ;
for (int i = ; i < k ; i++) {
bool flag = ;
for (int j = ; j < n ; j++) {
int l1 , l2 ;
char s1[] ;
char s2[] ;
strcpy (s1 , b[i]) ; l1 = strlen (s1) ; //puts (s1) ;
strcpy (s2 , a[j]) ; l2 = strlen (s2) ; //puts (s2) ;
if (l1 != l2)
continue ;
sort (s1 , s1 + l1 ) ; //puts (s1) ;
sort (s2 , s2 + l2 ) ; //puts (s2) ;
for (s = ; s < l1 ; s++) {
if (s1[s] != s2[s])
break ;
}
if (s == l1) {
printf ("%s\n" , a[j]) ;
flag = ;
}
}
if (!flag) {
puts ("NOT A VALID WORD") ;
puts ("******") ;
}
else {
puts ("******") ;
}
}
return ;
}
Word Amalgamation(枚举 + 排序)的更多相关文章
- poj1318 Word Amalgamation 字符串排序(qsort)
Word Amalgamation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9794 Accepted: 4701 ...
- ZOJ1181 Word Amalgamation 字符串 排序查找
传送门:ZOJ1181 思路:自身排序来判断两个字符串拥有相同的字符. #include<cstdio> #include<cstdlib> #include<io ...
- hdu-----(1113)Word Amalgamation(字符串排序)
Word Amalgamation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu1113 Word Amalgamation(详解--map和string的运用)
版权声明:本文为博主原创文章.未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/35338617 转载请注明出 ...
- HDOJ.1113 Word Amalgamation(map)
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输 ...
- 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 ...
- OpenMP之枚举排序
// EnumSort.cpp : 定义控制台应用程序的入口点. //枚举排序 /* 枚举排序(Enumeration Sort)是一种最简单的排序算法,通常也称为秩排序(Rank Sort). 该算 ...
- Word Amalgamation(hdoj1113)
Word Amalgamation Problem Description In millions of newspapers across the United States there is a ...
随机推荐
- RF源码阅读(碎片纪录)-Python积木之contextlib
参考页面: http://docs.python.org/2/library/contextlib.html contextlib是为了配合with语句来使用的.使用起来更加简洁.本来想写一下,这位同 ...
- 学习笔记——Maven实战(三)多模块项目的POM重构
重复,还是重复 程序员应该有狗一般的嗅觉,要能嗅到重复这一最常见的坏味道,不管重复披着怎样的外衣,一旦发现,都应该毫不留情地彻底地将其干掉.不要因为POM不是产品代码而纵容重复在这里发酵,例如这样一段 ...
- wpf键盘记录器
很简单的一个wpf键盘记录器 这个程序我一样用了全局勾子,之前用的都是winform上运行了,前一段时间 在国外的论坛上逛看到了一个wpf能用的就做了一个小程序记录一下,为了方便大家直关的看我在页面上 ...
- cookie的操作
比如这样如果一个网站上有两个域名的时候,我们需要考虑,两个域名下的cookie. 我们所说的跨域只的就是lesport.com和le.com js的cookie是不能跨域的,为了防止过大. js增加删 ...
- 20.C#LINQ基础和简单使用(十一章11.1-11.2)
终于看到了第11章,之前虽然也有看过,但没有太仔细,在工作中也偶尔会使用,但不明白其中的原理,那现在就来讲讲LINQ,做一做书虫~~ 首先先了解下LINQ的三个要点: LINQ不能把非常复杂的查询表达 ...
- iOS开发小技巧--字典和数组的中文输出
一.在解析json数据的时候,得到的集合对象或者数组对象在用%@打印的时候回出现类似乱码的情况.如图: 在iOS中打印字典或者数组对象,系统会默认调用字典对象和数组对象的descriptionWith ...
- hdu4287 字典树
#include<stdio.h> #include<string.h> #include<stdlib.h> #define maxn 10 struct tri ...
- shell--题目
1.有一个文件,里面有二列,第一列ip地址,第二列是时间,同一个ip可能出现多次,但时间不同. 文件类似下面的样子: 192.168.1.2 13:10 192.127.12 ...
- 打印cell的视图层次结构
#ifdef DEBUG NSLog(@"Cell recursive description:\n\n%@\n\n", [cell performSelector:@select ...
- 安装最新版本的ReSharper导致原生全局搜索工具的消失问题
经过检测,是由于启用了一个插件导致的,禁用即可,如下图: