HDU 1113 Word Amalgamation
来源:互联网 发布:excel重复数据合并求和 编辑:程序博客网 时间:2024/05/21 11:02
查看原题
题意
给出单词集合,再给错序单词,如果集合中有则输出,无则说明
思路
将集合中的单词作为索引,再用sort()排好序,作为值。
乱序中的单词也用sort()排序,查找map值中是否有相等的,有就输出索引
代码
#include <iostream>#include <string>#include <map>#include<algorithm> using namespace std;int main(int argc, char *argv[]){ map<string,string> m; string s,t; while(cin>>s&&s!="XXXXXX"){ t=s; sort(s.begin(),s.end()); m[t]=s; } while(cin>>s&&s!="XXXXXX"){ int flag=0; t=s; sort(s.begin(),s.end()); map<string,string>::iterator it;//遍历查找 for(it=m.begin();it!=m.end();it++){ if(it->second==s){//map的值相等 cout<<it->first<<endl;//输出map的索引值 flag=1; } } if(flag==0){ cout<<"NOT A VALID WORD"<<endl; } cout<<"******"<<endl; } return 0;}
0 0
- HDU 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu(1113)Word Amalgamation
- HDU 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- HDU 1113 Word Amalgamation
- HDU 1113-Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu 1113 Word Amalgamation
- hdu-1113 Word Amalgamation
- HDU 1113 Word Amalgamation
- HDU 1113 Word Amalgamation
- hdu 1113 Word Amalgamation (map)
- HDU 1113--Word Amalgamation【map】
- HDU 1113 — Word Amalgamation
- HDOJ HDU 1113 Word Amalgamation
- HDU 1113 Word Amalgamation 《map》
- ios 属性(属性变量)和成员变量
- 继承
- leetcode-107-Binary Tree Level Order Traversal II
- Android Studio环境的搭建
- Java在程序设计题目中的妙用
- HDU 1113 Word Amalgamation
- 移动端开发demo—移动端web相册(一)
- CUDA从入门到精通
- 使用Python爬取学校学生信息!(简单爬虫)
- STRUTS2中的OGNL
- Oracle学习之:RedHat 6.5 安装 11g数据库
- org.elasticsearch.client.transport.NoNodeAvailableException。。解决办法
- brtools备份与恢复
- 将本地工程上传到github