STL 맵 사용 POJ2503
1646 단어 dictionarystringeachinputup
Time Limit: 3000MS
Memory Limit: 65536K
Total Submissions: 18487
Accepted: 7978
Description
You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.
Input
Input consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message of up to 100,000 words. Each dictionary entry is a line containing an English word, followed by a space and a foreign language word. No foreign word appears more than once in the dictionary. The message is a sequence of words in the foreign language, one word on each line. Each word in the input is a sequence of at most 10 lowercase letters.
Output
Output is the message translated to English, one word per line. Foreign words not in the dictionary should be translated as "eh".
Sample Input
dog ogday
cat atcay
pig igpay
froot ootfray
loops oopslay
atcay
ittenkay
oopslay
Sample Output
cat
eh
loops
#include #include #include #include #include #include using namespace std; int main() { int len; char str1[12],str2[12],fstr[30]; string temp; map dic;//freopen("E://input.txt","r",stdin); while (gets(fstr)) { if (strlen(fstr)==0) break; sscanf(fstr,"%s %s",str1,str2); dic[string(str2)]=string(str1); } while (scanf("%s",&str2)!=EOF) { temp=dic[string(str2)]; if (temp.length()==0) printf("eh/n"); else printf("%s/n",temp.c_str()); } return 0; }
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
용어가 있는 초안에서 어휘 목록을 유지하는 방법내가 (공개적으로 표시되지 않음, 이후 알게 됨)에 쓴 것처럼 나는 (저도 가지고 있고 정기적으로 사용하는)과 같은 인기 사전 앱보다 선호합니다. 어쩐지 사전에 반드시 나오지 않는 단어를 저장할 수 있다는 생각은 L...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.