lmarkov

Fir Tree

Dec 14th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 FirTree
  8. {
  9.     class FirTree
  10.     {
  11.         static void Main(string[] args)
  12.         {            
  13.             byte height = byte.Parse(Console.ReadLine());
  14.             char dot = '.';
  15.             char star = '*';
  16.             int points = (height*2) - 2;              
  17.             int starsCount = 1;
  18.             int dotsCount = points - starsCount;
  19.             for (int i = 1; i < height; i++)
  20.             {
  21.                 for (int j = 0; j < dotsCount/2; j++)
  22.                 {
  23.                     Console.Write("{0}", dot);
  24.                 }
  25.                 for (int j = 0; j < starsCount; j++)
  26.                 {
  27.                     Console.Write("{0}", star);
  28.                 }
  29.                 for (int j = 0; j < dotsCount/2; j++)
  30.                 {
  31.                     Console.Write("{0}", dot);
  32.                 }                
  33.                 starsCount += 2;
  34.                 dotsCount = points - starsCount;
  35.                 Console.WriteLine();
  36.             }
  37.             starsCount = 1;
  38.             dotsCount = points - starsCount;
  39.             for (int j = 0; j < dotsCount / 2; j++)
  40.             {
  41.                 Console.Write("{0}", dot);
  42.             }
  43.             for (int j = 0; j < starsCount; j++)
  44.             {
  45.                 Console.Write("{0}", star);
  46.             }
  47.             for (int j = 0; j < dotsCount / 2; j++)
  48.             {
  49.                 Console.Write("{0}", dot);
  50.             }
  51.             Console.WriteLine();
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment