Advertisement
Guest User

Untitled

a guest
Dec 6th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.17 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 _04_EasterMaster
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             //int n = 4;
  15.             int totalCols = (3 * n) + 1;
  16.             int eggWidth = (3 * n) - 1;
  17.             int totalRows = 2 * n;
  18.             int topAndBottomSize = n - 1;
  19.             int topAndBottomEmptySpaces = (totalCols - topAndBottomSize) / 2;
  20.             int startSideRow = (totalRows - n) / 2;
  21.             int endSideRow = (totalRows + n) / 2;
  22.  
  23.             char[,] matrix = new char[totalRows, totalCols];
  24.  
  25.             //drawing dots everywhere
  26.             for (int row = 0; row < totalRows; row++)
  27.             {
  28.                 for (int col = 0; col < totalCols; col++)
  29.                 {
  30.                     matrix[row, col] = '.';
  31.                 }
  32.             }
  33.  
  34.             //first row empy spaces
  35.             for (int row = 0; row < totalRows; row++)
  36.             {
  37.                 for (int col = topAndBottomEmptySpaces; col < topAndBottomSize + topAndBottomEmptySpaces; col++)
  38.                 {
  39.                     if (row == 0 || row == totalRows - 1)
  40.                     {
  41.                         matrix[row, col] = '*';
  42.                     }
  43.                 }
  44.             }
  45.  
  46.             //printing sides
  47.             for (int row = startSideRow; row < endSideRow; row++)
  48.             {
  49.                 for (int col = 0; col < totalCols; col++)
  50.                 {
  51.                     if (col == 1 || col == totalCols - 2)
  52.                     {
  53.                         matrix[row, col] = '*';
  54.                     }
  55.                 }
  56.             }
  57.  
  58.  
  59.            
  60.  
  61.             //print inside
  62.             for (int col = 3; col < totalCols - 2; col++)
  63.             {
  64.  
  65.                 matrix[totalRows / 2 - 1, col] = '#';
  66.                 col++;
  67.             }
  68.  
  69.             for (int col = 2; col < totalCols - 2; col++)
  70.             {
  71.  
  72.                 matrix[totalRows / 2, col] = '#';
  73.                 col++;
  74.             }
  75.  
  76.             // print side ribbons
  77.             int closeStartRibbon = (totalCols - topAndBottomSize) / 2 - 2;
  78.             int farStartRibbon = (totalCols + topAndBottomSize) / 2 + 1;
  79.             int counter = closeStartRibbon;
  80.             for (int row = 1; row < totalRows; row++)
  81.             {
  82.                 for (int col = 1; col <= closeStartRibbon; col++)
  83.                 {
  84.                     if (col == counter)
  85.                     {
  86.                         matrix[row, col] = '*';
  87.                         counter -= 2;
  88.                     }
  89.                 }
  90.             }
  91.  
  92.             counter = farStartRibbon;
  93.             for (int row = 1; row < totalRows; row++)
  94.             {
  95.                 for (int col = farStartRibbon; col < totalCols - 2; col++)
  96.                 {
  97.                     if (col == counter)
  98.                     {
  99.                         matrix[row, col] = '*';
  100.                         counter += 2;
  101.                         row++;
  102.                     }
  103.                 }
  104.             }
  105.  
  106.             counter = closeStartRibbon;
  107.             for (int row = totalRows - 2; row > 0; row--)
  108.             {
  109.                 for (int col = 1; col <= closeStartRibbon; col++)
  110.                 {
  111.                     if (col == counter)
  112.                     {
  113.                         matrix[row, col] = '*';
  114.                         counter -= 2;
  115.                     }
  116.                 }
  117.             }
  118.  
  119.             counter = farStartRibbon;
  120.             for (int row = totalRows - 2; row > 0; row--)
  121.             {
  122.                 for (int col = farStartRibbon; col < totalCols - 2; col++)
  123.                 {
  124.                     if (col == counter)
  125.                     {
  126.                         matrix[row, col] = '*';
  127.                         counter += 2;
  128.                         row--;
  129.                     }
  130.                 }
  131.             }
  132.  
  133.             //printing matrix
  134.             for (int row = 0; row < totalRows; row++)
  135.             {
  136.                 for (int col = 0; col < totalCols; col++)
  137.                 {
  138.                     Console.Write(matrix[row, col]);
  139.                 }
  140.                 Console.WriteLine();
  141.             }
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement