Advertisement
MaoChessy

Task 7

Oct 22nd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  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;
  10.             string message;
  11.  
  12.             Console.Write("Введите сообщение для повторения - ");
  13.             message = Console.ReadLine();
  14.  
  15.             input:
  16.             Console.Write("Введите количество повторения сообщения. Отрицательное число, станет положительным. Количество - ");
  17.             if(!int.TryParse(Console.ReadLine(), out repetitionAmounts))
  18.             {
  19.                 Console.WriteLine("Некорректное число. Попробуйте ещё раз.");
  20.                 goto input;
  21.             }
  22.  
  23.             if (repetitionAmounts < 0)
  24.                 repetitionAmounts *= -1;
  25.  
  26.             counter = 0;
  27.             while (counter != repetitionAmounts)
  28.             {
  29.                 Console.WriteLine($"Повторение №{counter+1} : "+message);
  30.                 counter++;
  31.             }
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement