Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Input
- //The input data should be read from the console.
- //On the only input line you have an integer number N, showing the height of the tree.
- //The input data will always be valid and in the format described. There is no need to check it explicitly.
- //Output
- //The output data should be printed on the console.
- //You must print the fir tree on the console. Each row contains only characters "." (point) or "*" (asterisk).
- //The first row should have exactly one "*" in the middle (that is the top of the tree) and each of the next lines two more.
- //The last line should have exactly one asterisk in the middle, showing the stem of the tree.
- class Program
- {
- static void Main()
- {
- int hight = int.Parse(Console.ReadLine());
- int length = 1;
- for (int i = 2; i < hight; i++)
- {
- length += 2;
- }
- //Console.WriteLine(length);
- for (int j = 1; j <= length; j += 2)
- {
- for (int i = 1; i <= (length - j) / 2; i++)
- {
- Console.Write(".");
- }
- for (int i = 1; i <= j; i++)
- {
- Console.Write("*");
- }
- for (int i = 1; i <= (length - j) / 2; i++)
- {
- Console.Write(".");
- }
- Console.WriteLine();
- }
- //last row
- for (int i = 1; i <= length / 2; i++)
- {
- Console.Write(".");
- }
- Console.Write("*");
- for (int i = 1; i <= length/ 2; i++)
- {
- Console.Write(".");
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement