#C13831. Concatenate Words
Concatenate Words
Concatenate Words
You are given a list of words. Your task is to concatenate these words into a single string, with each word separated by exactly one space. Note that a word can be an empty string. In particular, if the list is empty, you should output an empty string.
Formally, let the list of words be \(w_1, w_2, \dots, w_n\). You must output the string
[ S = w_1 ; \Vert ; " " ; \Vert ; w_2 ; \Vert ; " " ; \Vert ; \dots ; \Vert ; " " ; \Vert ; w_n, ]
where (\Vert) denotes string concatenation. There will be exactly (n-1) spaces if (n > 0), and no extra spaces at the beginning or end of the output.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(n\), which indicates the number of words.
- The following \(n\) lines each contain a single word. Note that a word can be an empty string.
outputFormat
Print the concatenated string to standard output (stdout). The output should consist of the given words joined by a single space.
## sample2
hello
world
hello world