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