Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FirTree
- {
- static void Main()
- {
- //Telerik Academy
- //Christmas Eve is coming so even programmers got to prepare!
- //In the spirit of the event your task is to write a program that prints a fir tree to the console.
- //On the only input line you have an integer number N, showing the height of the tree.
- int n = int.Parse(Console.ReadLine());
- int stars = 1;
- int dots = 2*n - 3;
- int dots1;
- int dots2;
- int starsCycle = stars;
- dots1 = dots2 = dots/2;
- for (int row = 1; row < n; row++)
- {
- while (dots1 > 0)
- {
- Console.Write(".");
- dots1--;
- }
- while (starsCycle > 0)
- {
- Console.Write("*");
- starsCycle--;
- }
- while (dots2 > 0)
- {
- Console.Write(".");
- dots2--;
- }
- Console.WriteLine("");
- dots -= 2;
- stars += 2;
- dots1 = dots2 = (dots / 2);
- starsCycle = stars;
- }
- stars = 1;
- dots = 2 * n - 3;
- starsCycle = stars;
- dots1 = dots2 = dots / 2;
- for (int row = 1; row == 1; row++)
- {
- while (dots1 > 0)
- {
- Console.Write(".");
- dots1--;
- }
- while (starsCycle > 0)
- {
- Console.Write("*");
- starsCycle--;
- }
- while (dots2 > 0)
- {
- Console.Write(".");
- dots2--;
- }
- Console.WriteLine("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment