RadoslavStamboliev

05.Триъгълник

Aug 9th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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 Триъгълник
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N = int.Parse(Console.ReadLine());
  14.  
  15.  
  16.             int width = (4 * N) + 1;
  17.             int height = (2 * N) + 1;
  18.             int dots = 1;
  19.             int hash = 2 * N - 1; //(4 * N - 3) / 2;
  20.             int spaces = 1;
  21.  
  22.             Console.WriteLine(new string('#', width));
  23.  
  24.             for (int row = 1; row <= N; row++)
  25.             {
  26.                 if (row == N / 2 + 1)
  27.                 {
  28.  
  29.                     Console.WriteLine("{0}{1}{2}(@){2}{1}{0}", new string('.', dots), new string('#', hash)
  30.                     , new string(' ', (spaces - 3) / 2), new string('#', hash), new string('.', dots));
  31.                     dots++;
  32.                     hash -=2;
  33.                     spaces += 2;
  34.                 }
  35.  
  36.                 else
  37.                 {
  38.                     Console.WriteLine("{0}{1}{2}{1}{0}",
  39.             new string('.', dots),
  40.             new string('#', hash),
  41.             new string(' ', spaces));
  42.                     dots++;
  43.                     hash -= 2;
  44.                     spaces += 2;
  45.  
  46.                 }
  47.             }
  48.  
  49.             hash = 2 * N - 1; ;
  50.             for (int row = 1; row <= N; row++)
  51.             {
  52.                 Console.WriteLine("{0}{1}{0}",
  53.                     new string('.', dots),
  54.                     new string('#', hash));
  55.  
  56.                 dots++;
  57.                 hash -= 2;
  58.  
  59.  
  60.             }
  61.  
  62.  
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment