#K51802. Reverse a String
Reverse a String
Reverse a String
You are given a single string S
of length \(n\). Your task is to output the reverse of the string. The reversal of a string \(S = s_1 s_2 \cdots s_n\) is defined as \(S_{rev} = s_n s_{n-1} \cdots s_1\).
Example:
- If
S = "hello"
, then the result is"olleh"
. - If
S = " spaces "
, then the result is" secaps "
.
Your solution should read the input string from stdin
and output the reversed string to stdout
.
inputFormat
The input consists of a single line containing the string S
. The string may contain spaces and symbols.
Input Example:
hello
outputFormat
Output the reverse of the input string.
Output Example:
olleh## sample
hello
olleh