123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- /* Задача 1
- var symbols = "ABCEHKMOPTXY";
- var digits = "0123456789";
- while (true)
- {
- Console.Write("Номер: ");
- var number = Console.ReadLine();
- if (number.Length == 6)
- {
- for (int i = 0; i < number.Length; i++)
- {
- if (i > 0 && i < 4)
- {
- if (!digits.Contains(number[i]))
- {
- Console.WriteLine("bad digit");
- break;
- }
- }
- else if (!symbols.Contains(number[i]))
- {
- Console.WriteLine("bad symbol");
- break;
- }
- }
- }
- else if (number.Length < 6 | number.Length > 6)
- {
- Console.WriteLine("bad length");
- }
- }
- */
- /* Задача 2
- string[] binary = new string[]
- {
- "a", "a", "b", "c", "d", "e", "f", "g",
- "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w",
- "x", "y", "z"
- };
- while (true)
- {
- int a = 0;
- string otvet = String.Empty;
- Console.Write("binary code: ");
- string code = Console.ReadLine();
- for (int i = 0; i < code.Length; i++)
- {
- if (code[i] == '0')
- {
- a++;
- }
- else if (code[i] == '1')
- {
- a++;
- Console.Write(binary[a]);
- a = 0;
- }
- else
- {
- Console.WriteLine();
- Console.WriteLine("bad symbol");
- break;
- }
- if (i == (int)code.Length-1)
- {
- Console.WriteLine();
- }
- }
- }
- */
- /* Задача 3
- while (true)
- {
- int i = 0;
- int arrows1 = 0;
- int arrows2 = 0;
- Console.Write("arrows: ");
- string str = Console.ReadLine();
- int count = str.Length;
- while (count != 0)
- {
- if (str.IndexOf("<--<<",i,count) != -1)
- {
- i = str.IndexOf("<--<<", i, count) + 5;
- count = str.Length - i;
- arrows1++;
- }
- else
- {
- break;
- }
- }
- count = str.Length;
- i = 0;
- while (count != 0)
- {
- if (str.IndexOf(">>-->",i,count) != -1)
- {
- i = str.IndexOf(">>-->", i, count) + 5;
- count = str.Length - i;
- arrows2++;
- }
- else
- {
- break;
- }
- }
- Console.WriteLine(arrows1 + arrows2);
- }
- */
- /* Задача 4
- int a = 0, count = 0;
- Console.Write("Секунды: ");
- long seconds = long.Parse(Console.ReadLine());
- while (seconds > 0)
- {
- a += ((int)seconds % 10);
- seconds /= 10;
- }
- count++;
- int b = a;
- a = 0;
- if (b > 10)
- {
- while (b >= 10)
- {
- while (b > 0)
- {
- a += ((int)b % 10);
- b /= 10;
- }
- count++;
- b = a;
- a = 0;
- }
-
- Console.Write($"Число: {b}, итераций: {count}");
- }
- else
- {
- Console.Write($"Число: {a}, итераций: {count}");
- }
- */
- while (true)
- {
- string str = String.Empty;
- string str2 = String.Empty;
- Console.Write("first name: ");
- string[] string1 = Console.ReadLine().ToLower().Split(' ');
- for (int i = 0; i < string1.Length; i++)
- {
- str = str + string1[i];
- }
- Console.Write("second name: ");
- string[] string2 = Console.ReadLine().ToLower().Split(' ');
- for (int i = 0; i < string2.Length; i++)
- {
- str2 = str2 + string2[i];
- }
- for (int i = 0; i < str2.Length; i++)
- {
- for (int j = 0; j < str2.Length - i - 1; j++)
- {
- if((str2[j]) > (str2[j + 1]))
- {
- string a = str2[j].ToString();
- string b = str2[j + 1].ToString();
- str2 = str2.Remove(j, 1).Insert(j, b);
- str2 = str2.Remove((j + 1), 1).Insert(j + 1, a);
- }
- }
- }
- for (int i = 0; i < str.Length; i++)
- {
- for (int j = 0; j < str.Length - i - 1; j++)
- {
- if((str[j]) > (str[j + 1]))
- {
- string a = str[j].ToString();
- string b = str[j + 1].ToString();
- str = str.Remove(j, 1).Insert(j, b);
- str = str.Remove((j + 1), 1).Insert(j + 1, a);
- }
- }
- }
- if (string.Compare(str2,str) == 0)
- {
- Console.WriteLine("Yes");
- }
- else
- {
- Console.WriteLine("No");
- }
- }
|