Advertisement
Martichka

ExamPrep/ Task 3 Fir Tree

Dec 16th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. class FirTree
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         if ((n > 3) && (n < 101))
  8.         {
  9.             for (int treeRow = 0; treeRow < n - 1; treeRow++)
  10.             {
  11.                 int pointCount = n - 2 - treeRow;
  12.                 int asteriskCount = 2 * treeRow + 1;
  13.                 for (int point = 0; point < pointCount; point++)
  14.                 {
  15.                     Console.Write(".");
  16.                 }
  17.                 for (int point = 0; point < asteriskCount; point++)
  18.                 {
  19.                     Console.Write("*");
  20.                 }
  21.                 for (int point = 0; point < pointCount; point++)
  22.                 {
  23.                     Console.Write(".");
  24.                 }
  25.  
  26.                 Console.WriteLine("");
  27.             }
  28.             for (int stemRow = 0; stemRow < 1; stemRow++)
  29.             {
  30.                 for (int point = 1; point <= (n - 2 - stemRow); point++)
  31.                 {
  32.                     Console.Write(".");
  33.                 }
  34.                 for (int asterisk = 0; asterisk < 1; asterisk++)
  35.                 {
  36.                     Console.Write("*");
  37.                 }
  38.                 for (int point = 1; point <= (n - 2 - stemRow); point++)
  39.                 {
  40.                     Console.Write(".");
  41.                 }
  42.                 Console.WriteLine("");
  43.             }
  44.         }
  45.         else
  46.         {
  47.             Console.WriteLine("Wrong Value!");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement