#C10357. Filter Words by Prefix
Filter Words by Prefix
Filter Words by Prefix
You are given a list of words and a prefix. Your task is to output all words from the list that start with the given prefix, preserving their original order.
A word w is said to start with prefix p if the first \( |p| \) characters of w are exactly p (i.e. \( w[0:|p|] = p \)).
If no words match the prefix, output an empty line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer N on the first line indicating the number of words.
- The next N lines each contain a single word.
- The last line contains the prefix string.
outputFormat
Print all words that start with the given prefix in one line, separated by a single space. If no words match, output an empty line.
## sample6
apple
app
apricot
banana
grape
application
app
apple app application