zoukankan      html  css  js  c++  java
  • hdu 1075 map

    题意:给一个字典,和一句话,翻译一下

    奇怪的格式

    Sample Input
    START
    from fiwo
    hello difh
    mars riwosf
    earth fnnvk
    like fiiwj
    END
    START
    difh, i'm fiwo riwosf.
    i fiiwj fnnvk!
    END
     
    Sample Output
    hello, i'm from mars.
    i like earth!
     1 #include<cstdio>
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cmath>
     6 #include<queue>
     7 #include<map>
     8 using namespace std;
     9 #define MOD 1000000007
    10 const double eps=1e-5;
    11 #define cl(a) memset(a,0,sizeof(a))
    12 #define ts printf("*****
    ");
    13 const int MAXN=1005;
    14 map<string,string> mp;
    15 int n,m,tt;
    16 int main()
    17 {
    18     int i,j,k;
    19     #ifndef ONLINE_JUDGE
    20     freopen("1.in","r",stdin);
    21     #endif
    22     string str1,str2;
    23     cin>>str1;
    24     while(cin>>str1)
    25     {
    26         if(str1=="END") break;
    27         cin>>str2;
    28         mp[str2]=str1;
    29     }
    30     cin>>str1;
    31     char ch;
    32     ch=getchar();
    33     str1="";
    34     while(1)
    35     {
    36         while(1)
    37         {
    38             scanf("%c",&ch);
    39             if(!((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')))   break;
    40             str1+=ch;
    41         }
    42         if(str1=="END") break;
    43         if(mp.find(str1)==mp.end()) cout<<str1;    //并未在字典中找到
    44         else cout<<mp[str1];
    45         str1="";
    46         printf("%c",ch);    //符号或空格
    47     }
    48     return 0;
    49 }
  • 相关阅读:
    BZOJ 1024: [SCOI2009]生日快乐
    BZOJ 3038: 上帝造题的七分钟2
    BZOJ 2005: [Noi2010]能量采集
    费用流&网络流模版
    BZOJ 1070: [SCOI2007]修车
    BZOJ 3039: 玉蟾宫
    BZOJ 1022: [SHOI2008]小约翰的游戏John
    BZOJ 2456: mode
    BZOJ 1015: [JSOI2008]星球大战starwar
    Unity实现IOS原生分享
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4433702.html
Copyright © 2011-2022 走看看