HDU 1075-What Are You Talking About(map),hdu1075-what

來源:互聯網
上載者:User

HDU 1075-What Are You Talking About(map),hdu1075-what

題目連結:傳送門

字典樹。。

題意:給以部字典,英文和火星文對照的,再給一篇火星文,要求把火星文翻譯成英文(字典中沒有的火星文直接原樣輸出)

map水過。。

#include <algorithm>#include <iostream>#include <cstring>#include <cstdlib>#include <string>#include <cctype>#include <vector>#include <cstdio>#include <cmath>#include <queue>#include <stack>#include <map>#include <set>#define maxn 360#define _ll __int64#define ll long long#define INF 0x3f3f3f3f#define Mod 1000000007#define pp pair<int,int>#define ull unsigned long long#define max(x,y) ( ((x) > (y)) ? (x) : (y) )#define min(x,y) ( ((x) > (y)) ? (y) : (x) )using namespace std;char str[3010];int main(){map <string,string> m;char x[12],y[12],word[12];scanf("%s",x);while(~scanf("%s",x)&&x[0]!='E'){scanf("%s",y);string ta(x),tb(y);m[y]=x;}scanf("%s",x);getchar();while(gets(str)&&str[0]!='E'){int len=strlen(str),i=0;while(i<len){if(str[i]<'a'||str[i]>'z'){putchar(str[i++]);continue;}int p=0;while((str[i]>='a'&&str[i]<='z')&&i<len)word[p++]=str[i++];word[p]='\0';string sb(word);if(m.count(sb))printf("%s",m[sb].c_str());elseprintf("%s",word);}puts("");}return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.