#K63312. Find the Middle Character(s) of a String
Find the Middle Character(s) of a String
Find the Middle Character(s) of a String
Given a non-empty string s, your task is to extract and return the middle character(s) of the string.
If the length of s is odd, return the single middle character. If the length is even, return the two middle characters.
More formally, let ( n = |s| ) be the length of the string. If ( n ) is odd, output ( s[\lfloor n/2 \rfloor] ). If ( n ) is even, output ( s[\frac{n}{2}-1]s[\frac{n}{2}] ).
inputFormat
The input consists of a single line containing the string s.
outputFormat
Output the middle character (if s has odd length) or the middle two characters (if s has even length) of the string.## sample
test
es