Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
[代码]请问这样为什么会RE?用map写的#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator