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

纯stl, 1500MS

Posted by yimmon at 2012-05-27 21:59:02 on Problem 2503
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>

using namespace std;

string str1, str2;
map<string, string> m;
char str[100], c_str1[50], c_str2[50];

int main()
{
    while(gets(str) && str[0] != '\0')
    {
        sscanf(str, "%s %s", c_str1, c_str2);
        str1.assign(c_str1);
        str2.assign(c_str2);
        m[str2] = str1;
    }
    while(scanf("%s", str) != EOF)
    {
        str1.assign(str);
        map<string, string>::iterator ret = m.find(str1);
        if(ret == m.end())
            puts("eh");
        else
            puts((*ret).second.c_str());
    }
    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