Venciity

[SoftUni C# exam preparation] 03.ForestRoad

Apr 9th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 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 star = 0;
  9.             for (int row = 0; row < n; row++)
  10.             {
  11.                 for (int col = 0; col < n; col++)
  12.                 {
  13.                     if (col == star)
  14.                     {
  15.                         Console.Write("*");
  16.                     }
  17.                     else
  18.                     {
  19.                         Console.Write(".");
  20.                     }
  21.                 }
  22.                 Console.WriteLine();
  23.                 star++;
  24.             }
  25.  
  26.             star -= 2;
  27.  
  28.             for (int row = 0; row < n - 1; row++)
  29.             {
  30.                 for (int col = 0; col < n; col++)
  31.                 {
  32.                     if (col == star)
  33.                     {
  34.                         Console.Write("*");
  35.                     }
  36.                     else
  37.                     {
  38.                         Console.Write(".");
  39.                     }
  40.                 }
  41.                 Console.WriteLine();
  42.                 star--;
  43.             }
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment