Advertisement
Stann

Problem 3 - Fir Tree

Mar 5th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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.             int n = int.Parse(Console.ReadLine());
  14.             int width = n * 2 - 3;
  15.             Console.Write(new string('.', width / 2));
  16.             Console.Write('*');
  17.             Console.Write(new string('.', width / 2));
  18.             Console.WriteLine();
  19.             for (int i = 1; i < n / 2; i++)
  20.             {
  21.                 Console.Write(new string('.', width / 2 - i));
  22.                 Console.Write(new string('*', i + i + 1));
  23.                 Console.Write(new string('.', width / 2 - i));
  24.                 Console.WriteLine();
  25.             }
  26.             for (int i = n / 2; i < n-1; i++)
  27.             {
  28.                 Console.Write(new string('.', width / 2 - i));
  29.                 Console.Write(new string('*', i + i + 1));
  30.                 Console.Write(new string('.', width / 2 - i));
  31.                 Console.WriteLine();
  32.             }
  33.             Console.Write(new string('.', width / 2 ));
  34.             Console.Write('*');
  35.             Console.Write(new string('.', width / 2 ));
  36.             Console.WriteLine();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement