SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | ||
| 3 | namespace C_sharp_Light | |
| 4 | {
| |
| 5 | class Program | |
| 6 | {
| |
| 7 | static void Main(string[] args) | |
| 8 | {
| |
| 9 | - | int repetitionAmounts, counter; |
| 9 | + | int repetitionAmount; |
| 10 | string message; | |
| 11 | ||
| 12 | Console.Write("Введите сообщение для повторения - ");
| |
| 13 | message = Console.ReadLine(); | |
| 14 | ||
| 15 | - | input: |
| 15 | + | while (true) |
| 16 | - | Console.Write("Введите количество повторения сообщения. Отрицательное число, станет положительным. Количество - ");
|
| 16 | + | |
| 17 | - | if(!int.TryParse(Console.ReadLine(), out repetitionAmounts)) |
| 17 | + | Console.Write("Введите количество повторения сообщения. Отрицательное число, станет положительным. Количество - ");
|
| 18 | if (!int.TryParse(Console.ReadLine(), out repetitionAmount)) | |
| 19 | - | Console.WriteLine("Некорректное число. Попробуйте ещё раз.");
|
| 19 | + | {
|
| 20 | - | goto input; |
| 20 | + | Console.WriteLine("Некорректное число. Попробуйте ещё раз.");
|
| 21 | continue; | |
| 22 | } | |
| 23 | - | if (repetitionAmounts < 0) |
| 23 | + | break; |
| 24 | - | repetitionAmounts *= -1; |
| 24 | + | |
| 25 | ||
| 26 | - | counter = 0; |
| 26 | + | if (repetitionAmount < 0) |
| 27 | - | while (counter != repetitionAmounts) |
| 27 | + | repetitionAmount *= -1; |
| 28 | ||
| 29 | - | Console.WriteLine($"Повторение №{counter+1} : "+message);
|
| 29 | + | for (int counter = 0; counter < repetitionAmount; counter++) |
| 30 | - | counter++; |
| 30 | + | |
| 31 | Console.WriteLine($"Повторение №{counter + 1} : " + message);
| |
| 32 | } | |
| 33 | Console.ReadKey(); | |
| 34 | } | |
| 35 | } | |
| 36 | } |