Advertisement
Hristo_B

Forest Road

May 28th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2.  
  3. class ForestRoad
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int width = n;
  9.         int height = 2 * n - 1;
  10.         char asterisk = '*';
  11.         int position = 0;
  12.  
  13.         char[] trees = { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'};
  14.        
  15.         for (int coll = 0; coll < height; coll++)
  16.         {
  17.             for (int row = 0; row < width; row++)
  18.             {
  19.                 while (position < width)
  20.                 {
  21.                     trees[position] = asterisk;
  22.                     for (int i = 0; i < width; i++)
  23.                     {
  24.                         Console.Write(trees[i]);
  25.                     }
  26.                     trees[position] = '.';
  27.                     position++;
  28.                     Console.WriteLine();
  29.                 }
  30.  
  31.                 while (position <= width)
  32.                 {
  33.                     position-= 2;
  34.                     trees[position] = asterisk;
  35.                     for (int i = 0; i < width; i++)
  36.                     {
  37.                         Console.Write(trees[i]);
  38.                     }
  39.                     trees[position] = '.';
  40.                     position++;
  41.                     Console.WriteLine();
  42.                 }
  43.  
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement