Advertisement
Montagne94

14. Вывод имени

Jan 7th, 2025 (edited)
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | Source Code | 0 0
  1. using System;
  2.  
  3. namespace HomeWork
  4. {
  5.     internal class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             Console.Write("Введите символ для рамки: ");
  10.             char borderChar = Console.ReadKey().KeyChar;
  11.             Console.WriteLine();
  12.  
  13.             Console.Write("Введите имя: ");
  14.             string name = Console.ReadLine();
  15.            
  16.             string nameLine = $"{borderChar}{name}{borderChar}";
  17.             int frameWidth = nameLine.Length;
  18.             string borderLine = new string(borderChar, frameWidth);
  19.            
  20.             Console.WriteLine(borderLine);
  21.             Console.WriteLine(nameLine);
  22.             Console.WriteLine(borderLine);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement