Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Write a program that prints on the console the border of a trapezoid by given number N.
- //The width of the top side of the trapezoid must be exactly N.
- //The width of the bottom side of the trapezoid must be exactly 2 * N.
- //The height of the trapezoid must be exactly N + 1.
- //Also the top right and the bottom right angle of the trapezoid must be equal to 90 degrees.
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- for (int j = 0; j < n+1; j++)
- {
- for (int i = 0; i < 2 * n; i++)
- {
- if (j == 0) //first row
- {
- if (i + n >= 2 * n)
- {
- Console.Write("*");
- }
- else
- {
- Console.Write(".");
- }
- }
- if (j == n) //last row
- {
- Console.Write("*");
- }
- else if(j > 0) //mid rows
- {
- if (i == n - j || i == 2 * n - 1)
- {
- Console.Write("*");
- }
- else
- {
- Console.Write(".");
- }
- }
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement