Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.         public static bool CreateRectangle(string widthString)
  2.         {
  3.             int width = Int32.Parse(widthString);
  4.            
  5.             for(int y = 0; y < width; y++)
  6.             {
  7.                 for (int x = 0; x < width; x++)
  8.                 {
  9.                     if (y == width - 1)
  10.                         Console.Write("*");
  11.                     else if (x == 0 && y != width - 1)
  12.                         Console.Write("*");
  13.                     else if (x == y && y != width - 1)
  14.                         Console.Write("*");
  15.                     else if (x != y && x != 0 && y != width - 1)
  16.                         Console.Write(" ");
  17.                 }
  18.                 Console.WriteLine();
  19.             }
  20.             return true;
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement