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

学习的紫书的map= =

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

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

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<vector>
  5. #include<algorithm>
  6. #include<cctype>
  7. #include<set>
  8. #include<map>
  9. using namespace std;
  10.  
  11. map<string,int> cnt;
  12. vector<string> words;
  13. vector<string> ans;
  14.  
  15. string repr(const string& s)
  16. {
  17. string ans=s;
  18. for(int i=;i<ans.length();i++)
  19. ans[i]=tolower(ans[i]);
  20. sort(ans.begin(),ans.end());
  21. return ans;
  22. }
  23.  
  24. int main()
  25. {
  26. string s;
  27. while(cin>>s)
  28. {
  29. if(s[]=='#') break;
  30. words.push_back(s);
  31. string r=repr(s);
  32. if(!cnt.count(r)) cnt[r]=;
  33. cnt[r]++;
  34. }
  35. for(int i=;i<words.size();i++)
  36. if(cnt[repr(words[i])]==) ans.push_back(words[i]);
  37.  
  38. sort(ans.begin(),ans.end());
  39. for(int i=;i<ans.size();i++)
  40. cout<<ans[i]<<"\n";
  41. return ;
  42. }

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. 哪些问题困扰着我们?DevOps 使用建议

    [编者按]随着 DevOps 被欲来越多机构采用,一些共性的问题也暴露出来.近日,Joe Yankel在「Devops Q&A: Frequently Asked Questions」一文中总 ...

  2. NodeJS模块、包、NPM

    1.NodeJS模块        每一个Nodejs都是一个NodeJS模块,包括JS文件,JSON文本文件,二进制模块文件. a.模块的应用               新建一个文件mytest. ...

  3. uva 11294

    Problem E: Wedding Up to thirty couples will attend a wedding feast, at which they will be seated on ...

  4. POJ 3484

    Showstopper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1060   Accepted: 303 Descri ...

  5. iOS 隐藏顶部状态栏方式和更改颜色

    plist文件里面添加 AppDelegate: //显示状态栏 [[UIApplication sharedApplication]setStatusBarHidden:NO]; //将状态栏颜色设 ...

  6. POJ 2075

    #include<iostream> #include<stdio.h> #include<string> #include<map> #include ...

  7. java 如何从配置文件(.properties)中读取内容

    1.如何创建.properties文件 很简单,建立一个txt文件,并把后缀改成.properties即可 2.将.properties文件拷入src的根目录下 3..properties文件内容格式 ...

  8. regexp_substr在oracle9i的替换方案

    regexp_substr()方法在oracle9i尚不存在,是从oracle10g开始新增,如下为替换解决方法. SELECT regexp_substr('|83~GT67XVFU0RCVIV|6 ...

  9. linux下如何查看主机的外网ip地址

    在linux下如果我们使用的是nat方式上网.通过ifconfig命令查看到的ip地址往往是内网地址 那么如何查看主机在互联网上使用的公网IP呢?我们可以在命令行下使用curl命令实现这个功能. [r ...

  10. lintcode:将二叉查找树转换成双链表

    题目 将一个二叉查找树按照中序遍历转换成双向链表 给定一个二叉查找树: 4 / \ 2 5 / \ 1 3 返回 1<->2<->3<->4<->5. ...