Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 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 _05.Triangle
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             //Printing The First Line
  16.             Console.WriteLine(new string('#', (4*n) + 1));
  17.  
  18.             //Making some help variables for count of symbols
  19.             var dotsCount = 1;
  20.             var spacesCount = 1;
  21.  
  22.             //Printing Next N Lines
  23.             for (int i = 0; i < n; i++)
  24.             {
  25.                 var diesCount = (((4 * n) + 1) - (2 * dotsCount + spacesCount)) / 2;
  26.  
  27.                 //Checking for the middle line
  28.                 if (i == n / 2)
  29.                 {
  30.                     //TODO some logic here for middle line
  31.                     Console.WriteLine(new string('.', dotsCount) +
  32.                         new string('#', diesCount) + new string(' ', (spacesCount - 3) / 2) +
  33.                         "(@)" + new string(' ', (spacesCount - 3) / 2) +
  34.                         new string('#', diesCount) + new string('.', dotsCount));
  35.                 }
  36.                 else
  37.                 {
  38.                     //Printing Lines where there is not eye
  39.                     Console.WriteLine(new string('.', dotsCount) +
  40.                         new string('#', diesCount) + new string(' ', spacesCount) +
  41.                         new string('#', diesCount) + new string('.', dotsCount));
  42.                 }
  43.  
  44.                 dotsCount++;
  45.                 spacesCount += 2;
  46.             }
  47.  
  48.             //Printing the final lines here
  49.             //They are N count
  50.  
  51.             //Changing the variables for the first line
  52.             spacesCount -= 2;
  53.             var bottomDiesCount = spacesCount;
  54.  
  55.             for (int i = 0; i < n; i++)
  56.             {
  57.                 Console.WriteLine(new string('.', dotsCount) +
  58.                     new string('#', bottomDiesCount) + new string('.', dotsCount));
  59.                 dotsCount++;
  60.                 bottomDiesCount -= 2;
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement