Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Trapezoid
- {
- class Trapezoid
- {
- static void Main()
- {
- //Input
- int N = int.Parse(Console.ReadLine());
- int rows = N + 1;
- int cols = 2 * N;
- int[,] matrix = new int[rows, cols];
- //Fill the matrix
- for (int col = N; col < cols; col++)
- {
- matrix[0, col] = 1;
- }
- for (int row = 1; row < rows; row++)
- {
- matrix[row, cols - 1] = 1;
- }
- for (int col = cols - 1; col >= 0; col--)
- {
- matrix[rows - 1, col] = 1;
- }
- //int currentRow = 0;
- int currentCol = 0;
- for (int row = rows - 1; row >= 0; row--)
- {
- matrix[row, currentCol] = 1;
- currentCol++;
- }
- //Output
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- if (matrix[row, col] == 0)
- {
- Console.Write(".");
- }
- else if (matrix[row, col] == 1)
- {
- Console.Write("*");
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement