Загрузка данных
using System;
class Program
{
static void Main()
{
// 1
Console.Write("Введите предложение: ");
string s1 = Console.ReadLine();
s1 = s1.Replace('е', 'и');
Console.WriteLine(s1);
// 2
Console.Write("Введите предложение: ");
string s2 = Console.ReadLine();
s2 = s2.Replace(' ', '_');
Console.WriteLine(s2);
// 3
Console.Write("Введите предложение: ");
string s3 = Console.ReadLine();
char[] chars3 = s3.ToCharArray();
for (int i = 1; i < chars3.Length; i += 2)
chars3[i] = 'ы';
s3 = new string(chars3);
Console.WriteLine(s3);
// 4
Console.Write("Введите предложение: ");
string s4 = Console.ReadLine();
char[] chars4 = s4.ToCharArray();
for (int i = 2; i < chars4.Length; i += 3)
chars4[i] = 'а';
s4 = new string(chars4);
Console.WriteLine(s4);
// 5
Console.Write("Введите предложение: ");
string s5 = Console.ReadLine();
s5 = s5.Replace("ах", "ух");
Console.WriteLine(s5);
// 6
Console.Write("Введите предложение: ");
string s6 = Console.ReadLine();
s6 = s6.Replace("да", "не");
Console.WriteLine(s6);
// 7
Console.Write("Введите предложение: ");
string s7 = Console.ReadLine();
s7 = s7.Replace("про", "нет");
Console.WriteLine(s7);
// 8
Console.Write("Введите предложение: ");
string s8 = Console.ReadLine();
s8 = s8.Replace("бит", "рог");
Console.WriteLine(s8);
// 9
Console.Write("Введите предложение: ");
string s9 = Console.ReadLine();
Console.Write("Введите подстроку s1: ");
string s1_9 = Console.ReadLine();
Console.Write("Введите подстроку s2: ");
string s2_9 = Console.ReadLine();
s9 = s9.Replace(s1_9, s2_9);
Console.WriteLine(s9);
// 10
string s10 = "очепатка";
s10 = s10.Replace("оче", "опе");
Console.WriteLine(s10);
// 11
Console.Write("Введите слово: ");
string s11 = Console.ReadLine();
if (s11.Length < 5)
{
Console.WriteLine("Слово слишком короткое");
}
else
{
char[] chars11 = s11.ToCharArray();
char temp11 = chars11[1];
chars11[1] = chars11[4];
chars11[4] = temp11;
s11 = new string(chars11);
Console.WriteLine(s11);
}
// 12
Console.Write("Введите слово: ");
string s12 = Console.ReadLine();
if (s12.Length < 3)
{
Console.WriteLine("Слово слишком короткое");
}
else
{
char[] chars12 = s12.ToCharArray();
char temp12 = chars12[2];
chars12[2] = chars12[s12.Length - 1];
chars12[s12.Length - 1] = temp12;
s12 = new string(chars12);
Console.WriteLine(s12);
}
// 13
Console.Write("Введите слово: ");
string s13 = Console.ReadLine();
Console.Write("Введите m: ");
int m13 = int.Parse(Console.ReadLine());
Console.Write("Введите n: ");
int n13 = int.Parse(Console.ReadLine());
if (m13 < 1 || n13 > s13.Length || m13 == n13)
{
Console.WriteLine("Некорректные значения");
}
else
{
char[] chars13 = s13.ToCharArray();
char temp13 = chars13[m13 - 1];
chars13[m13 - 1] = chars13[n13 - 1];
chars13[n13 - 1] = temp13;
s13 = new string(chars13);
Console.WriteLine(s13);
}
// 14
Console.Write("Введите слово (чётное число букв): ");
string s14 = Console.ReadLine();
if (s14.Length % 2 != 0)
{
Console.WriteLine("Количество букв нечётное");
}
else
{
char[] chars14 = s14.ToCharArray();
for (int i = 0; i < s14.Length / 2; i += 2)
{
char temp14 = chars14[i];
chars14[i] = chars14[i + 1];
chars14[i + 1] = temp14;
}
s14 = new string(chars14);
Console.WriteLine(s14);
}
// 15
Console.Write("Введите слово (чётное число букв): ");
string s15 = Console.ReadLine();
if (s15.Length % 2 != 0)
{
Console.WriteLine("Количество букв нечётное");
}
else
{
char[] chars15 = s15.ToCharArray();
int half15 = s15.Length / 2;
for (int i = 0; i < half15; i++)
{
char temp15 = chars15[i];
chars15[i] = chars15[s15.Length - 1 - i];
chars15[s15.Length - 1 - i] = temp15;
}
s15 = new string(chars15);
Console.WriteLine(s15);
}
}
}