Advertisement
svetlyoek

Untitled

Feb 15th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp169
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string text = Console.ReadLine();
  10. MiddleCharPrint(text);
  11. }
  12.  
  13. private static void MiddleCharPrint(string text)
  14. {
  15. if(text.Length%2==0)
  16. {
  17. Console.Write($"{text[text.Length/2-1]}{text[text.Length/2]}");
  18. Console.WriteLine();
  19. }
  20. else
  21. {
  22. Console.Write($"{text[text.Length/2]}");
  23. Console.WriteLine();
  24. }
  25.  
  26.  
  27.  
  28.  
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement