POJ2503--(STLmap应用)

题目:http://poj.org/problem?id=2503


题意很简单直接上代码:

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<stdio.h>
#include<map>

using namespace std;

int main()
{
     string s;
     string first,second;
     map<string,string>  m;
     while( getline(cin,s) )
     {
         if( s.empty() )       
         {
             break;    
         } 
         int pos = s.find(" ");
         first = s.substr(0,pos);
         second = s.substr(pos+1,s.length()-pos-1);
         m[second] = first;
         //cout<<m[second]<<endl;
     }
   
     string ss;
     while(cin>>ss)
     {
         if( !m[ss].empty())             
         {
             cout<<m[ss]<<endl;    
         }
         else
         {
             cout<<"eh"<<endl;
         }
     }
     
     //system("pause");
     return 0;
} 

Run ID User Problem Result Memory Time Language Code Length Submit Time
12375294 niuliguo 2503 Accepted 16160K 2969MS G++ 805B 2013-12-13 09:18:18





你可能感兴趣的:(数据结构,C++,map,poj)