Advertisement
holllowknight

ДЗ: Вывод имени

Mar 9th, 2020 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Name
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string name;
  10.             char frameSymbol;
  11.             string horizontalLine = "";
  12.             int stringWidth;
  13.             string formattedName;
  14.  
  15.             Console.Write("Введите имя: ");
  16.             name = Console.ReadLine();
  17.             Console.Write("Символ для рамки: ");
  18.             frameSymbol = Convert.ToChar(Console.ReadLine());
  19.             formattedName = $"{frameSymbol} {name} {frameSymbol}";
  20.             stringWidth = formattedName.Length;
  21.  
  22.             for (int i = 0; i < stringWidth; i++)
  23.             {
  24.                 horizontalLine += frameSymbol;
  25.             }
  26.  
  27.             Console.WriteLine(horizontalLine);
  28.             Console.WriteLine(formattedName);
  29.             Console.WriteLine(horizontalLine);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement