Advertisement
Qrist

Middle Characters

Apr 14th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         string st = Console.ReadLine();
  7.         MiddleChar(st);
  8.     }
  9.     public static void MiddleChar(string st)
  10.     {
  11.         if(st.Length%2!=0)
  12.         {
  13.             Console.WriteLine(st[st.Length/2]);
  14.         }
  15.         else
  16.         {
  17.             Console.WriteLine($"{st[st.Length/2-1]}{st[st.Length/2]}");
  18.         }      
  19.     }  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement