码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1113 Word Amalgamation (map)

时间:2014-08-06 11:56:21      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:os   io   for   amp   ios   algorithm   hdu   return   

# include <stdio.h>
# include <string>
# include <map>
# include <iostream>
# include <algorithm>
using namespace std;
int main()
{
	string s,t;
	int flag;
	map<string,string>q;
	while(cin>>s&&s!="XXXXXX")
	{
		t=s;
		sort(s.begin(),s.end());
		q[t]=s;
	}
	while(cin>>s&&s!="XXXXXX")
	{
		sort(s.begin(),s.end());
		map<string,string>::iterator it;
		flag=0;
		for(it=q.begin();it!=q.end();it++)
		{
			if(it->second==s)
			{
				cout<<it->first<<endl;
				flag=1;
			}
		}
		if(!flag)
			cout<<"NOT A VALID WORD"<<endl;
		cout<<"******"<<endl;
	}
	return 0;
}

hdu 1113 Word Amalgamation (map),布布扣,bubuko.com

hdu 1113 Word Amalgamation (map)

标签:os   io   for   amp   ios   algorithm   hdu   return   

原文地址:http://blog.csdn.net/lp_opai/article/details/38398117

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!