Advertisement
Venciity

[SoftUni C# exam preparation] 03.FirTree

Apr 9th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 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. class FirTree
  8. {
  9.     static void Main()
  10.     {
  11.         int n = Int32.Parse(Console.ReadLine());
  12.         int hegiht = n;
  13.         int width = 2 * n - 3;
  14.  
  15.         int stars = 1;
  16.         int dots = width/2;
  17.         for (int i = 0; i < hegiht - 1; i++)
  18.         {
  19.             string dotsString = new string('.', dots);
  20.             string starsString = new string('*', stars);
  21.             Console.WriteLine("{0}{1}{0}",dotsString, starsString);
  22.             stars = stars + 2;
  23.             dots = dots - 1;
  24.         }
  25.  
  26.         string lastDotsString = new string('.', width / 2);
  27.         string lastStarsString = new string('*', 1);
  28.         Console.WriteLine("{0}{1}{0}", lastDotsString, lastStarsString);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement