Advertisement
ktopchiev

Triangle

Dec 9th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Triangle
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int dots = 1;
  15.             int grids = n * 2 - 1;
  16.             int spaces = 1;
  17.  
  18.             Console.WriteLine(new string ('#', (n * 4) + 1));
  19.             for (int u = 1; u <= n; u++)
  20.             {
  21.                 Console.WriteLine(new string('.', dots) + new string('#', grids) + new string(' ', spaces) + new string('#', grids) + new string('.', dots));
  22.                 dots++;
  23.                 grids -= 2;
  24.                 spaces += 2;
  25.                 if (grids < 1)
  26.                 {
  27.                     break;
  28.                 }
  29.                 if (u == n / 2)
  30.                 {
  31.                     Console.WriteLine(new string('.', dots) + new string('#', grids) + new string(' ', n / 2 - 1) + "(@)"+ new string(' ', n / 2 - 1) + new string('#', grids) + new string('.', dots));
  32.                     dots++;
  33.                     grids -= 2;
  34.                     if (grids < 1)
  35.                     {
  36.                         break;
  37.                     }
  38.                     spaces += 2;
  39.                 }
  40.             }
  41.             int dots2 = n + 1;
  42.             int grids2 = n * 2 - 1;
  43.             for (int d = 0; d < n; d++)
  44.             {
  45.                 Console.WriteLine(new string('.', dots2) + new string('#', grids2) + new string('.', dots2));
  46.                 dots2++;
  47.                 grids2 -= 2;
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement