Advertisement
desislava_topuzakova

Triangle of Stars

Jul 9th, 2022
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P07.TriangleOfStarts
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //   *
  10.             //  ***
  11.             // *****
  12.             //*******
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             for (int row = 1; row <= n; row++)
  16.             {
  17.                 for (int spaces = 1; spaces <= n - row; spaces++)
  18.                 {
  19.                     Console.Write(' ');
  20.                 }
  21.  
  22.                 for (int asterisks = 0; asterisks < 2 * row - 1; asterisks++)
  23.                 {
  24.                     Console.Write('*');
  25.                 }
  26.  
  27.                 for (int spaces = 1; spaces <= n - row; spaces++)
  28.                 {
  29.                     Console.Write(' ');
  30.                 }
  31.  
  32.                 Console.WriteLine();
  33.                 //Console.WriteLine($"{new string(' ', n - row)}{new string('*', 2 * row - 1)}{new string(' ', n - row)}");
  34.             }
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement