Advertisement
MaoChessy

Task 7 - fix

Oct 22nd, 2020 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace C_sharp_Light
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int repetitionAmount;
  10.             string message;
  11.  
  12.             Console.Write("Введите сообщение для повторения - ");
  13.             message = Console.ReadLine();
  14.  
  15.             while (true)
  16.             {
  17.                 Console.Write("Введите количество повторения сообщения. Отрицательное число, станет положительным. Количество - ");
  18.                 if (!int.TryParse(Console.ReadLine(), out repetitionAmount))
  19.                 {
  20.                     Console.WriteLine("Некорректное число. Попробуйте ещё раз.");
  21.                     continue;
  22.                 }
  23.                 break;
  24.             }
  25.  
  26.             if (repetitionAmount < 0)
  27.                 repetitionAmount *= -1;
  28.  
  29.             for (int counter = 0; counter < repetitionAmount; counter++)
  30.             {
  31.                 Console.WriteLine($"Повторение №{counter + 1} : " + message);
  32.             }
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement