Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace lab
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Введите текст");
- string c = Console.ReadLine();
- string v = c;
- int t = 1;
- int r = 0;
- int i = 0;
- int k = 0;
- int d = 0;
- while (t == 1)
- {
- i = 0;
- r = -1;
- k = 0;
- while (i < c.Length)
- {
- k = 0;
- for (int f = i; f < c.Length; f++)
- {
- if (c[f] == ' ')
- {
- d = f;
- break;
- }
- else
- {
- r++;
- i++;
- }
- }
- if (r % 2 == 0)
- {
- for (int f = i - r - 1; f <(i-r-1)+r/2; f++)
- {
- string j = Char.ToString(c[f]);
- v = c.Remove(f, 1);
- c = v.Insert(f, Char.ToString(c[f + r - k]));
- v = c.Remove(f + r - k, 1);
- c = v.Insert(f + r - k, j);
- k += 2;
- }
- }
- else
- {
- for (int f = i - r - 1; f <(i-r-1)+(r/ 2 + 0.5); f++)
- {
- string j = Char.ToString(c[f]);
- v = c.Remove(f, 1);
- c = v.Insert(f, Char.ToString(c[f + r - k]));
- v = c.Remove(f + r - k, 1);
- c = v.Insert(f + r - k, j);
- k += 2;
- }
- }
- r = -1;
- if (i < (c.Length-1))
- {
- i=d;
- i++;
- }
- }
- Console.WriteLine("ИТОГ: ");
- Console.WriteLine();
- Console.WriteLine(c);
- Console.WriteLine();
- Console.WriteLine("Совершить обратную операцию?");
- Console.WriteLine("1.Да 2.Нет");
- t = int.Parse(Console.ReadLine());
- if (t > 2 || t < 1)
- {
- while (t > 2 || t < 1)
- {
- Console.WriteLine("Таких вариантов нет. Либо 1, либо 2");
- t = int.Parse(Console.ReadLine());
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement