原题链接:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=92

整体思路如下:先建立一个 multimap<排序的词,未排序的词> 来处理输入,完毕后将只有一个值的键放入一个set中,最后遍历set输出即可。切忌不要误用成 map, 因为 multimap 允许重复元素,map 不允许有重复

更多有关 map 与 multimap 的区别可以查看这篇博客:https://blog.csdn.net/c_base_jin/article/details/51501214

下面就奉上 AC 代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map> using namespace std; char ch[25], origin[25]; multimap <string, string> mmp;
set <string> con; int main(void)
{
int len, i;
while (scanf("%s", ch), ch[0] != '#') {
strcpy(origin, ch);
len = strlen(ch); for (int i = 0; i < len; i++)
if (isupper(ch[i]))
ch[i] = tolower(ch[i]); sort(ch, ch + len);
mmp.insert(make_pair(ch, origin));
} multimap <string, string>::iterator xp;
set <string>::iterator it;
for (xp = mmp.begin(); xp != mmp.end(); xp++)
if (mmp.count(xp -> first) == 1)
con.insert(xp -> second);
for (it = con.begin(); it != con.end(); it++)
puts((*it).c_str()); return 0;
}

UVA 156 Ananagrams (STL multimap & set)的更多相关文章

  1. UVa 156 Ananagrams(STL,map)

     Ananagrams  Most crossword puzzle fans are used to anagrams--groups of words with the same letters ...

  2. uva 156 - Ananagrams (反片语)

    csdn:https://blog.csdn.net/su_cicada/article/details/86710107 例题5-4 反片语(Ananagrams,Uva 156) 输入一些单词,找 ...

  3. UVA 156 Ananagrams ---map

    题目链接 题意:输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排,得到输入文本中的另外一个单词.在判断是否满足条件时,字母不分大小写,但在输出时应保留输入中的大小写,按字典序进行排列( ...

  4. UVa 156 Ananagrams

    题意:给出一些单词,在这些单词里面找出不能通过字母重排得到的单词(判断的时候不用管大小写),然后按照字典序输出. 学习的紫书的map= = 将每一个单词标准化 先都转化为小写,再排序(即满足了题目中说 ...

  5. STL语法——映射:map 反片语(Ananagrams,UVa 156)

    Description Most crossword puzzle fans are used to anagrams--groups of words with the same letters i ...

  6. 【UVA - 156 】Ananagrams (set,map,vector)

    Ananagrams  Descriptions: Most crossword puzzle fans are used to anagrams--groups of words with the ...

  7. 反片语(Ananagrams,Uva 156)

    输入一些单词,找出所有满足如下条件的单词:该单词不能通过字母重排,得到输入文 本中的另外一个单词.在判断是否满足条件时,字母不分大小写,但在输出时应保留输入中 的大小写,按字典序进行排列(所有大写字母 ...

  8. Ananagrams UVA - 156

      Most crossword puzzle fans are used to anagrams - groups of words with the same letters in differe ...

  9. UVA 156:Ananagrams (vector+map+sort)

    题意:一大堆单词中间有空格隔开,以'#'结束输出,问只出现一次的的单词有哪些(如果两个具有相同的长度,相同的字母也算是相同的,不区分大小写,如:noel和lone属于一个单词出现两次).最后按照字典序 ...

随机推荐

  1. ABP VNext框架基础知识介绍(2)--微服务的网关

    ABP VNext框架如果不考虑在微服务上的应用,也就是开发单体应用解决方案,虽然也是模块化开发,但其集成使用的难度会降低一个层级,不过ABP VNext和ABP框架一样,基础内容都会设计很多内容,如 ...

  2. ubuntu 16.04下的fastadmin安装指南

    此篇博客转载于fastadmin论坛,方便自己看转到了博客里 说明文档不多,特制作一个,方便大家交流使用Ubuntu 16.04 安装fastadmin指南本文因考虑到大多数人员,习惯性在window ...

  3. Decorator 模式转载

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://tianli.blog.51cto.com/190322/35287 摘要:本文深 ...

  4. 『学了就忘』Linux系统管理 — 84、Linux中进程的管理

    目录 1.Linux系统中的信号 2.杀掉进程的命令 (1)kill命令 (2)killall命令 (3)pkill命令 1.Linux系统中的信号 Linux系统中可以识别的信号较多,我们可以使用命 ...

  5. [BUUCTF]REVERSE——[BJDCTF2020]easy

    [BJDCTF2020]easy 附件 例行检查,无壳,32位程序 32位ida载入,main函数和字符串理都没有找到有关flag的提示 根据main函数的提示,有关flag的函数应该被藏起来了,在左 ...

  6. MySQL 创建定时任务 详解

    自 MySQL5.1.6起,增加了一个非常有特色的功能–事件调度器(Event Scheduler),可以用做定时执行某些特定任务,来取代原先只能由操作系统的计划任务来执行的工作.事件调度器有时也可称 ...

  7. CF106A Card Game 题解

    Content 一种纸牌游戏有许多张卡牌,每张卡牌有一个套装(S,H,D和 C)和一个等级(按升序排列6,7,8,9,T, J,Q,K,A). 规定以下情况卡牌 A 才能赢卡牌 B: A 有王牌套装, ...

  8. IE上的兼容性调整问题烦死啦

    IE上的兼容性调整问题烦死啦 好像还得把此代码放到第一行才起作用.

  9. SpringBoot整合Netty实现socket通讯简单demo

    依赖 <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifa ...

  10. JAVA 接口返回JSON格式转换类

    使用了Lombok插件 Result.java package com.utils; import com.jetsum.business.common.constant.Constant; impo ...