#C12048. Reverse a String Without Built-in Functions
Reverse a String Without Built-in Functions
Reverse a String Without Built-in Functions
Given a string, your task is to reverse it without using any built-in reverse functions. You should implement the reversal logic manually by iterating over the string. This problem tests your understanding of string manipulation and basic loop constructs.
For example, given the input string "hello", the output should be "olleh". Similarly, a palindrome like "madam" will remain unchanged after reversal.
Note: You must read input from stdin
and write output to stdout
for the submitted solution.
You can refer to the following transformation formula in LaTeX for the reverse operation:
$$\text{reverse}(s) = s[n-1] \; s[n-2] \; \dots \; s[0]$$
inputFormat
The input consists of a single line containing a non-empty string s
, whose length does not exceed 105 characters.
Input is provided through stdin
.
outputFormat
Output a single line which is the reverse of the provided string.
Output must be written to stdout
.
hello
olleh