Advertisement
wulev

03. Trapezoid

Apr 9th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. // http://bgcoder.com/Contests/3/CSharp-Fundamentals-2011-2012-Part-1-Test-Exam
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace _03.Trapezoid
  10. {
  11.     class Trapezoid
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int n = int.Parse(Console.ReadLine());
  16.             int stars = n;
  17.             int dots = n;
  18.             int innerDots = n - 1;
  19.             DrawLine(dots, stars);
  20.             Console.WriteLine();
  21.             dots = n - 1;
  22.  
  23.             for (int i = 0; i < n-1; i++)
  24.             {
  25.                 stars = 1;
  26.                 Console.WriteLine("{0}{1}{2}{1}", new string ('.',dots), new string('*', stars),
  27.                     new string('.', innerDots));
  28.                 dots--;
  29.                 innerDots++;
  30.             }
  31.             stars = 2 * n;
  32.             Console.WriteLine("{0}", new string('*', stars));
  33.         }
  34.  
  35.         private static void DrawLine(int dots, int stars)
  36.         {
  37.             for (int i = 0; i <dots; i++)
  38.             {
  39.                 Console.Write(".");
  40.             }
  41.             for (int i = 0; i <stars; i++)
  42.             {
  43.                 Console.Write("*");
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement