archangelmihail

TelerikLogo

Dec 1st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.20 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 TelerikLogo
  8. {
  9.     class TelerikLogo
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // inicialization
  14.             int x = int.Parse(Console.ReadLine());
  15.             int y = x;
  16.             int z = x / 2 + 1;
  17.             int width = 2 * x + 2 * z - 3; // or 3*x -2
  18.             int height = 3 * x - 2;  // same as width
  19.             int[,] matrix = new int[height, width];
  20.             //solution
  21.             int currentRow = x / 2;
  22.             int currentCol = 0;
  23.            
  24.             while (true)
  25.             {
  26.                 matrix[currentRow, currentCol] = 1;
  27.                 currentCol++;
  28.                 currentRow--;
  29.                 if (currentRow < 0 )
  30.                 {
  31.                     currentRow++;
  32.                     currentCol--;
  33.                     break;
  34.                 }
  35.             }
  36.             while (true)
  37.             {
  38.                 matrix[currentRow, currentCol] = 1;
  39.                 currentCol++;
  40.                 currentRow++;
  41.                 if (currentRow == 2*x -1 )
  42.                 {
  43.                     currentRow--;
  44.                     currentCol--;
  45.                     break;
  46.                 }
  47.             }
  48.             while (true)
  49.             {
  50.                 matrix[currentRow, currentCol] = 1;
  51.                 currentCol--;
  52.                 currentRow++;
  53.                 if (currentRow == width)
  54.                 {
  55.                     currentRow--;
  56.                     currentCol++;
  57.                     break;
  58.                 }
  59.             }
  60.             while (true)
  61.             {
  62.                 matrix[currentRow, currentCol] = 1;
  63.                 currentCol--;
  64.                 currentRow--;
  65.                 if (currentCol == x/2 -1)
  66.                 {
  67.                     currentRow++;
  68.                     currentCol++;
  69.                     break;
  70.                 }
  71.             }
  72.             while (true)
  73.             {
  74.                 matrix[currentRow, currentCol] = 1;
  75.                 currentCol++;
  76.                 currentRow--;
  77.                 if (currentRow < 0)
  78.                 {
  79.                     currentRow++;
  80.                     currentCol--;
  81.                     break;
  82.                 }
  83.             }
  84.             while (true)
  85.             {
  86.                 matrix[currentRow, currentCol] = 1;
  87.                 currentCol++;
  88.                 currentRow++;
  89.                 if (currentCol == width)
  90.                 {
  91.                     currentRow--;
  92.                     currentCol--;
  93.                     break;
  94.                 }
  95.             }
  96.  
  97.  
  98.             // printing
  99.             for (int row = 0; row < height; row++)
  100.             {
  101.                 for (int col = 0; col < width; col++)
  102.                 {
  103.                     if (matrix [row,col] == 0)
  104.                     {
  105.                         Console.Write('.');
  106.                     }
  107.                     else
  108.                     {
  109.                         Console.Write('*');
  110.                     }
  111.                    
  112.                 }
  113.                 Console.WriteLine();
  114.             }
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment