Advertisement
ivan_yosifov

Trapezoid

Nov 11th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int N = int.Parse(Console.ReadLine());
  8.         int bottom = N * 2;
  9.         int height = N + 1;
  10.  
  11.         int leftDots = 0;
  12.         int rightDots = 0;
  13.         string row = null;
  14.  
  15.         // print top row
  16.         row = new string('.', N) + new string('*', N);
  17.         Console.WriteLine(row);
  18.  
  19.         for (int i = 0; i < height - 2; i++)
  20.         {
  21.             leftDots = N - i - 1;
  22.             rightDots = N - 1 + i;
  23.             row = new string('.', leftDots);
  24.             row += "*";
  25.             row += new string('.', rightDots);
  26.             row += "*";
  27.             Console.WriteLine(row);
  28.         }
  29.  
  30.         // print bottom row
  31.         row = new string('*', bottom);
  32.         Console.WriteLine(row);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement