Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ForestRoad
- {
- static void Main()
- {
- //Telerik Academy
- //Geeko, a non-stop learning trainee at Telerik Software Academy lived deep into the Lulin forests. Every time he went to the Academy he had to take a long trip through the forest. Starting from the top left corner of the forest, the road always goes down and right first and when it reaches the border, it goes down and left.
- //On the only line in the console you are given an integer number N, showing the width of the map. The map’s height is always 2*N - 1.
- int roadSize = int.Parse(Console.ReadLine()),
- starPos1 = 1,
- starPos2 = 1;
- for (int row = 1; row <= (2*roadSize - 1); row++)
- {
- for (int column = 1; column <= roadSize; column++)
- {
- if (row == starPos2 && column == starPos1)
- {
- Console.Write("*");
- }
- else
- {
- Console.Write(".");
- }
- }
- Console.WriteLine("");
- if (row >= ((2 * roadSize) / 2))
- {
- starPos1--;
- starPos2++;
- }
- else
- {
- starPos1++;
- starPos2++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment