首页 > 其他 > 详细

URAL 1545. Hieroglyphs

时间:2015-03-11 14:50:26      阅读:192      评论:0      收藏:0      [点我收藏+]

1545. Hieroglyphs

Time limit: 1.0 second
Memory limit: 64 MB
Vova is fond of anime. He is so enthusiastic about this art that he learned to communicate with his Japanese friends using their native language. However, for writing email messages Vova has to use Latin letters. He wants to type hieroglyphs from his keyboard. His team-mate Sergey, in order to help Vova, created an applet that makes it possible to write hieroglyphs by means of typing Latin letters on the keyboard. Each hieroglyph is represented by a sequence of two Latin letters. This correspondence is given in a special reference book compiled by Sergey. When the applet realizes that a sequence of Latin letters corresponding to a hieroglyph has been typed, it replaces the sequence with this hieroglyph.
When Vova started using Sergey‘s program, he quickly became bored of looking into the reference book so often. Help Sergey to upgrade the applet in such a way that for each typed Latin letter it would automatically supply a prompt helping to continue this letter to a sequence representing a hieroglyph.

Input

The first line contains the number of hieroglyphs in Sergey‘s reference book N (1 ≤ N ≤ 1000). Each of the next N lines contains a sequence of two lowercase Latin letters corresponding to a hieroglyph. The next line contains a lowercase Latin letter entered by Vova.

Output

Output sequences from the reference book that start with the given letter, one sequence per line, in an arbitrary order. If there are no such sequences, then output nothing.

Sample

input output
6
na
no
ni
ki
ka
ku
k
ka
ki
ku




题意:输出n个字符串中以给出的字母开头的字符串。顺序不限。

解析:遍历一遍即可。



AC代码:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

string s[1002];

int main(){
    #ifdef sxk
        freopen("in.txt", "r", stdin);
    #endif //sxk

    int n;
    char c;
    while(scanf("%d", &n)==1){
        for(int i=0; i<n; i++) cin>>s[i];
        cin>>c;
        for(int i=0; i<n; i++)
            if(s[i][0] == c) cout<<s[i]<<endl;
    }
    return 0;
}




URAL 1545. Hieroglyphs

原文:http://blog.csdn.net/u013446688/article/details/44197805

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!