/*
* UVA_630.cpp
*
* Created on: 2013年11月4日
* Author: Administrator
*/ #include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <algorithm> using namespace std; int main(){
int t;
scanf("%d",&t);
while(t--){
multimap <string,string> mp;
string str; int n;
scanf("%d",&n); int i;
for(i = 0 ; i < n ; ++i){
cin >>str; string temp = str;
sort(temp.begin(),temp.end());
mp.insert(make_pair(temp,str));//map中保存的数据形式是(有序串,原串) 有序串用于比较,原串用于输出
} while(cin >> str,str != "END"){ string tp = str;
sort(tp.begin(),tp.end()); cout<<"Anagrams for: "<<str<<endl;
int count = 1;
bool flag = false;
for(map<string,string>::iterator it = mp.begin() ; it != mp.end() ; ++it){
if(tp == (*it).first){
flag = true;
printf("%3d) %s\n",count++,(*it).second.c_str());
}
} if(flag == false){
cout<<"No anagrams for: "<<str<<endl;
}
} if(t){//注意:千万别漏了,测试数据之间要输出空行...
cout<<endl;
}
} return 0;
}

最新文章

  1. Method Swizzling (方法调配)
  2. Spring MVC + MyBatis整合(IntelliJ IDEA环境下)
  3. PL/SQL之--包
  4. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
  5. XE2编译出来的DLL的DLLMain的退出地方用到了halt0
  6. *****正则表达式匹配URL
  7. 腾讯云中ssL证书的配置安装
  8. ImCash:币安下架BSV之辩:规则、中立与去中心化
  9. wangEditor的使用
  10. Django 项目内利用ORM直接运行脚本读库
  11. MACD各分时背离所对应的时间
  12. [转]RabbitMQ系列(一):Windows下RabbitMQ安装及入门
  13. log4j.properties配置文件详解
  14. vscode调试js,安装了nodejs之后还出现无法在Path上找到运行时的node
  15. HTTP监视器charles入门使用教程分享---http/s packet monitors---ubuntu installation
  16. 利率计算v4.0--测试--软件工程
  17. MySQL Error: PROCEDURE xmdk.query_all_plan can&#39;t return a result set in the given context
  18. Git使用技巧(3)-- 远程操作
  19. 浏览器指纹--纯js拿到浏览器指纹
  20. ndarray:一种多维数组对象

热门文章

  1. 【Vue实战之路】一、Vue-cli入门及Vue工程目录全解。
  2. 二叉查找树(二叉排序树)的详细实现,以及随机平衡二叉查找树Treap的分析与应用
  3. Linux下实现自动设置SSH代理
  4. 一个页面从输入 URL 到页面加载显示完成,这个过程中都发生了什么?
  5. Codeforces Round #374 (Div. 2) C. Journey DP
  6. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
  7. CentOS下多网卡绑定多IP段时导致只有一个会通的问题解决
  8. KVM磁盘镜像qcow2、raw、vmdk等格式区别(转)
  9. 【转】JavaScript eval处理JSON数据 为什么要加括号
  10. 通过WinAPI播放PCM声音