Advertisement
Qrist

Rhombus of stars

Apr 18th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         int n=10;
  8.         for (int row = 1; row < n; row++)
  9.         {
  10.             var spaces = Math.Abs(n / 2 - row);
  11.             var stars = n / 2 - spaces;
  12.             for (int col = 1; col <= spaces; col++)
  13.             {
  14.                 Console.Write(" ");
  15.             }
  16.             for (int col = 1; col <= stars; col++)
  17.             {
  18.                 Console.Write("* ");
  19.             }
  20.             Console.WriteLine();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement