Advertisement
g-stoyanov

Contest80Task4TelerikLogo

Dec 29th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. class Contest80Task4TelerikLogo
  4. {
  5.     static void Main()
  6.     {
  7.         int input = int.Parse(Console.ReadLine());
  8.         int[,] matrix = new int[2 * input + (input - 2), 2 * input + (input - 2)];
  9.         int count = 0;
  10.         int x = 0;
  11.         int y = (input - input / 2) - 1;
  12.         int xMod = 1;
  13.         int yMod = -1;
  14.         while (count < 6)
  15.         {
  16.             if (count == 5 && x >= 2 * input + (input - 2) )
  17.             {
  18.                 break;
  19.             }
  20.             if (y == 0 || y == (2 * input + (input - 2)) - 1)
  21.             {
  22.                 yMod = yMod * -1;
  23.                 count++;
  24.             }
  25.             if (y == (2 * input) - 2)
  26.             {
  27.                 xMod = xMod * -1;
  28.                 count++;
  29.             }
  30.             matrix[y, x] = 1;
  31.             x = x + xMod;
  32.             y = y + yMod;
  33.         }
  34.         for (int i = 0; i < 2 * input + (input - 2); i++)
  35.         {
  36.             for (int a = 0; a < 2 * input + (input - 2); a++)
  37.             {
  38.                 if (matrix[i, a] == 1)
  39.                 {
  40.                     Console.Write("*");
  41.                 }
  42.                 else
  43.                 {
  44.                     Console.Write(".");
  45.                 }
  46.             }
  47.             Console.WriteLine();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement