Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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.
- //See the examples bellow.
- //Input
- //The input data is being read from the console.
- //On the only line in the console you are given an integer number N, showing the width of the smallest trapezoid side.
- //The input data will always be valid and in the format described. There is no need to check it explicitly.
- //Output
- //The output data must be printed on the console.
- //You must write the border of the described trapezoid on the console.
- //Use the symbol “*” (asterisk) to mark the border of the trapezoid.
- //Use the symbol “.” (dot) to illustrate the empty spaces outside and inside the trapezoid.
- //Constraints
- //• The number N is a positive integer between 3 and 39, inclusive.
- //• Allowed working time for your program: 0.25 seconds.
- //• Allowed memory: 16 MB.
- using System;
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- Console.WriteLine("{0}{1}", new string('.', n), new string('*', n));
- for (int i = 1; i < n; i++)
- {
- Console.Write("{0}", new string('.', n - i));
- Console.Write('*');
- Console.Write("{0}", new string('.', (n + i)-2));
- Console.Write('*');
- Console.WriteLine();
- }
- Console.WriteLine("{0}", new string('*', n*2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment