Advertisement
VladoG

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

May 31st, 2016
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 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_1_Square_of_Stars
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var N = int.Parse(Console.ReadLine());
  14.             if (N >= 2 && N <= 100)
  15.             {
  16.                 for (int i = 1; i <= N; i++)
  17.                 {
  18.                     Console.Write("*");
  19.                     for (int j = 2; j <= (N - 1); j++)
  20.                     {
  21.                         if (i == 1 || i == N)
  22.                         {
  23.                             Console.Write("*");
  24.                         }
  25.                         else
  26.                         {
  27.                             Console.Write(" ");
  28.                         }
  29.                     }
  30.                     Console.WriteLine("*");
  31.                 }
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement