Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

[代码]请问这样为什么会RE?用map写的

Posted by bigheadghost at 2007-02-08 21:38:56 on Problem 2503
#include<cstdio>
#include<map>
using namespace std;
struct ltstr{
	bool operator() (const char* a,const char* b)const
	{return strcmp(a,b)<0;}
};
map<char*,char*,ltstr> dict;
char line[10000],dt[100001][11];
int p=0;
int main()
{
	while(gets(line) && line[0])
	{
		p++;
		char *br=strchr(line,' ');
		*br=0;
		strcpy(dt[p],br+1);
		dict[dt[p++]]=strdup(line);
	}
	map<char*,char*,ltstr>::iterator it;
	while(scanf("%s",line)!=EOF)
		if((it=dict.find(line))!=dict.end())
			printf("%s\n",it->second);
		else
			puts("eh");	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator