grigorb57

Rhombus From Stars #2

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