题意:给出一些单词,在这些单词里面找出不能通过字母重排得到的单词(判断的时候不用管大小写),然后按照字典序输出。

学习的紫书的map= =

将每一个单词标准化 先都转化为小写,再排序(即满足了题目中说的不能通过字母重排这个条件) 然后记录出现次数,将出现次数为1的储存再输出

话说这一题的标准化要好好学学= =(字母重排用排序来做= =)

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
using namespace std; map<string,int> cnt;
vector<string> words;
vector<string> ans; string repr(const string& s)
{
string ans=s;
for(int i=;i<ans.length();i++)
ans[i]=tolower(ans[i]);
sort(ans.begin(),ans.end());
return ans;
} int main()
{
string s;
while(cin>>s)
{
if(s[]=='#') break;
words.push_back(s);
string r=repr(s);
if(!cnt.count(r)) cnt[r]=;
cnt[r]++;
}
for(int i=;i<words.size();i++)
if(cnt[repr(words[i])]==) ans.push_back(words[i]); sort(ans.begin(),ans.end());
for(int i=;i<ans.size();i++)
cout<<ans[i]<<"\n";
return ;
}

UVa 156 Ananagrams的更多相关文章

  1. uva 156 - Ananagrams (反片语)

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

  2. UVa 156 Ananagrams(STL,map)

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

  3. UVA 156 Ananagrams (STL multimap & set)

    原题链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&p ...

  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

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

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

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

  9. 反片语 (Ananagrams,UVa 156)

    题目描述: #include <iostream> #include <string> #include <cctype> #include <vector& ...

随机推荐

  1. JobClient学习------作业提交与初始化

    public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); ...

  2. 游戏引擎网络开发者的64做与不做(二A):协议与API

    [编者按]在这个系列之前的文章"游戏引擎网络开发者的64做与不做(一):客户端方面"中,Sergey介绍了游戏引擎添加网络支持时在客户端方面的注意点.本文,Sergey则将结合实战 ...

  3. GRID用法(取行、列值;定位选中某行等等)

    Delphi Cxgrid获取选中行列,排序规则,当前正在编辑的单元格内的值 cxGrid1DBTableView1.Controller.FocusedRowIndex 当前行号 cxGrid1DB ...

  4. jquery ajax post 传递数组 ,多checkbox 取值

    jquery ajax post 传递数组 ,多checkbox 取值 http://w8700569.iteye.com/blog/1954396 使用$.each(function(){});可以 ...

  5. javascript console

    javascript console console.log(object[, object, ...])在控制台输出一条消息.如果有多个参数,输出时会用空格隔开这些参数. 第一个参数可以是一个包含格 ...

  6. UVA 10943 How do you add? DP

    Larry is very bad at math — he usually uses a calculator, whichworked well throughout college. Unfor ...

  7. Linux下查看进程和线程

    在linux中查看线程数的三种方法 1.top -H 手册中说:-H : Threads toggle 加上这个选项启动top,top一行显示一个线程.否则,它一行显示一个进程. 2.ps xH 手册 ...

  8. Shell脚本基础I

    1.Linux shell类型 /bin/sh--已经被/bin/bash所取代 /bin/bash--就是Linux预设的shell /bin/ksh--由AT&T Bell lab发展出来 ...

  9. Java学习笔记之:Java JDBC

    一.介绍 JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用java语言编写 ...

  10. Spring Loaded is a JVM agent for reloading class file changes

    <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...