设为首页 加入收藏

TOP

poj2503――Babelfish
2014-11-23 20:00:38 来源: 作者: 【 】 浏览:1
Tags:poj2503 Babelfish

很水的一道题,但是处理两行之间的空格花了许多功夫,最后还是用了char,因为可以自由修改,相比string需要用insert函数,更加灵活一些。也可以用hash来做,不过有些麻烦就是了。

#include 
#include 
#include 
#include 
using namespace std;

int main()
{
	char d1[50],d2[50];
	string tp;
	map dic;
	int count=0;
	while(1)
	{
		char t=getchar(); 
		if(t=='\n')  
			break;
		else     
		{
			d1[0]=t;
			int i=1;
			while(1)
			{
				t=getchar();
				if(t==' ')
				{
					d1[i]='\0';
					break;
				}
				else
					d1[i++]=t;
			}
		}
		
		cin>>d2;
		getchar();  //吃掉 输入foreign后的 回车符
		dic[d2]=d1;
		count++;
	}
	string tar;
	while(cin>>tar)
	{
		map::iterator p=dic.find(tar);
		if(p==dic.end())
			cout<<"eh"< 
 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj--1611--并查集(路径压缩运用.. 下一篇http://poj.org/problem?id=1190

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python爬虫教程(从 (2025-12-26 16:49:14)
·【全269集】B站最详 (2025-12-26 16:49:11)
·Python爬虫详解:原 (2025-12-26 16:49:09)
·Spring Boot Java: (2025-12-26 16:20:19)
·Spring BootでHello (2025-12-26 16:20:15)