Advertisement
G_Burlakova

ForestRoad

Mar 31st, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 forestRoad
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         byte N = byte.Parse(Console.ReadLine());
  12.         if (N < 1 || N > 80)
  13.         {
  14.             return;
  15.         }
  16.         uint heith = (uint)2 * N - 1;
  17.         int pointsBeforeCount = 0;
  18.         int pointsAfterCount = N - 1;
  19.         string direction = "right";
  20.         string pointsBefore = "";
  21.         string pointsAfter = "";
  22.         for (int i = 1; i <= heith; i++)
  23.         {
  24.             if (direction.Equals("right"))
  25.             {
  26.                 pointsBefore = new string('.', pointsBeforeCount);
  27.                 pointsAfter = new string('.', (N - (pointsBeforeCount + 1)));
  28.                 pointsBeforeCount++;
  29.                 if (pointsBeforeCount == N)
  30.                 {
  31.                     pointsBeforeCount = N - 2;
  32.                     direction = "left";
  33.                 }
  34.             }
  35.             else if (direction.Equals("left"))
  36.             {
  37.                 pointsBefore = new string('.', pointsBeforeCount);
  38.                 pointsAfter = new string('.', (N - (pointsBeforeCount + 1)));
  39.                 pointsBeforeCount--;
  40.                 if (pointsBeforeCount == 0)
  41.                 {
  42.                     pointsBeforeCount = 0;
  43.                     direction = "right";
  44.                 }
  45.             }
  46.  
  47.  
  48.             Console.WriteLine("{0}*{1}", pointsBefore, pointsAfter);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement