Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._Middle_Characters
- {
- class Program
- {
- static void Main(string[] args)
- {
- string singalString = Console.ReadLine();
- bool isEven = true;
- FineMiddleCharecter(singalString, isEven);
- }
- static void FineMiddleCharecter(string singalString, bool isEven)
- {
- isEven = ChekEvenString(singalString, isEven);
- double middleSymbol = singalString.Length / 2;
- for (int i = 0; i < singalString.Length; i++)
- {
- if (isEven == false && i == middleSymbol)
- {
- Console.WriteLine(singalString[i]);
- }
- if (isEven == true && i == middleSymbol)
- {
- Console.Write($"{singalString[i-1]}{ singalString[i]}");
- Console.WriteLine();
- }
- }
- }
- static bool ChekEvenString(string singalString, bool isEven)
- {
- if (singalString.Length % 2 != 0)
- {
- isEven = false;
- }
- return isEven;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment