Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _6._MiddleCharacters
- {
- class MiddleCharacters
- {
- static void Main()
- {
- string word = Console.ReadLine();
- Console.WriteLine(GetMiddleCharacter(word));
- }
- static string GetMiddleCharacter(string word)
- {
- string middleChar = null;
- if (word.Length % 2 == 1)
- {
- middleChar = word[word.Length / 2].ToString();
- }
- else
- {
- middleChar = word[word.Length / 2 - 1].ToString() + word[word.Length / 2].ToString();
- }
- return middleChar;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement