Advertisement
braveheart1989

Rhombus of Stars

Jun 14th, 2016
1,408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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. using System.Globalization;
  7.  
  8. class Program
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int n = int.Parse(Console.ReadLine());
  13.         int stars = 1;
  14.         int spaces = n - stars;
  15.  
  16.         for (int row = 0; row < n; row++)
  17.         {
  18.             for (int col = 0; col < spaces; col++)
  19.             {
  20.                 Console.Write(" ");
  21.             }
  22.             for (int col = 0; col < stars; col++)
  23.             {
  24.                 Console.Write("* ");
  25.             }
  26.             spaces--;
  27.             stars++;
  28.             Console.WriteLine();
  29.         }
  30.  
  31.        
  32.         spaces = 1;
  33.         stars = n - spaces;
  34.         for (int row = n; row < 2*n; row++)
  35.         {
  36.            
  37.             for (int col = 0; col < spaces; col++)
  38.             {
  39.                 Console.Write(" ");
  40.             }
  41.             for (int col = 0; col < stars; col++)
  42.             {
  43.                 Console.Write("* ");
  44.             }
  45.             spaces++;
  46.             stars--;
  47.             Console.WriteLine();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement