Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Drafty
- {
- class Program
- {
- public static void ReverseHalfes(string source)
- {
- if (source.Length % 2 != 0)
- {
- Console.WriteLine("Строка должна быть чётной!");
- return;
- }
- string firstHalf = ReverseString(source.Substring(0, source.Length / 2));
- string secondHalf = ReverseString(source.Substring(source.Length / 2, source.Length / 2));
- Console.WriteLine(firstHalf + secondHalf);
- }
- public static string ReverseString(string source)
- {
- string result = "";
- for (int i = source.Length - 1; i >= 0; i--)
- {
- result += source[i];
- }
- return result;
- }
- static void Main(string[] args)
- {
- Console.Write("Введите чётную строку: ");
- ReverseHalfes(Console.ReadLine());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment