LusienGG

[C#] Rhombus of Stars

Apr 17th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 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 Practice
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             // Top side
  15.             for (int i = 1; i <= n; i++)
  16.             {
  17.                 Console.Write(new string(' ', n - i));
  18.                 for (int j = 0; j < i; j++)
  19.                 {
  20.                     Console.Write("* ");
  21.                 }
  22.                 Console.WriteLine(new string(' ', n - i));
  23.             }
  24.             // Bottom side
  25.             for (int i = n-1 ; i >= 1; i--)
  26.             {
  27.                 Console.Write(new string(' ', n - i));
  28.                 for (int j = 0; j < i; j++)
  29.                 {
  30.                     Console.Write("* ");
  31.                 }
  32.                 Console.WriteLine(new string(' ', n - i));
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment