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