archangelmihail

ForesRoad

Nov 30th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 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 ForesRoad
  8. {
  9.     class ForesRoad
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int path = 0;
  15.             int position = 0;
  16.             char tree = '*';
  17.             char grass = '.';
  18.             bool turn = false;
  19.             while (path < 2 * n - 1)
  20.             {
  21.                 if (position == 0)
  22.                 {
  23.                     Console.Write(tree);
  24.                     Console.Write(new string (grass, n - 1));
  25.                     position++;
  26.                     Console.WriteLine();
  27.                 }
  28.                 else if (position > 0 && position < n - 1 && !turn)
  29.                 {
  30.                     Console.Write(new string(grass,position));
  31.                     Console.Write(tree);
  32.                     Console.Write(new string(grass,n-position-1));
  33.                     position++;
  34.                     Console.WriteLine();
  35.                 }
  36.                 else if (position == n-1 )
  37.                 {
  38.                     Console.Write(new string(grass, n - 1));
  39.                     Console.Write(tree);
  40.                     turn = true;
  41.                     position--;
  42.                     Console.WriteLine();
  43.                 }
  44.                 else if (turn && position > 0 && position < n - 1 )
  45.                 {
  46.                     Console.Write(new string(grass, position));
  47.                     Console.Write(tree);
  48.                     Console.Write(new string(grass, n - position -1));
  49.                     Console.WriteLine();
  50.                     position--;
  51.                 }
  52.                 else
  53.                 {
  54.                     Console.Write(tree);
  55.                     Console.Write(new string(grass, n - 1));
  56.                     Console.WriteLine();
  57.                     break;
  58.                 }
  59.                
  60.                 path++;
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment