Advertisement
VladoG

First Steps in Coding - 08. Square of Stars (with STRINGs)

May 31st, 2016
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _05_08_2_Square_of_Stars_STRING
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             string stars = new string('*', n);
  15.             Console.WriteLine(stars);
  16.  
  17.             for (int i = 1; i <= n - 2; i++)
  18.             {
  19.                 string stars1 = "*" + new string(' ', n - 2) + "*";
  20.                 Console.WriteLine(stars1);
  21.             }
  22.             // in the beginning string was init -> stars = new string('*', n);
  23.             Console.WriteLine(stars);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement