Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class TelerikLogo
- {
- static void Main()
- {
- //initialization
- int x = Int32.Parse(Console.ReadLine());
- int y = x;
- int z = (x / 2) + 1;
- int width = (2 * x + 2 * z) - 3; // -3 защото се x и z се застъпват на 3 места ( ъглите )
- int height = width;
- int[,] matrix = new int[height, width];
- // solution - filling the path with ones (1)
- int currentRow = x / 2;
- int currentCol = 0;
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow--;
- currentCol++;
- if (currentRow < 0)
- {
- currentRow++;
- currentCol--;
- break;
- }
- }
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow++;
- currentCol++;
- if (currentRow == 2 * x - 1 )
- {
- currentRow--;
- currentCol--;
- break;
- }
- }
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow++;
- currentCol--;
- if (currentRow == width)
- {
- currentRow--;
- currentCol++;
- break;
- }
- }
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow--;
- currentCol--;
- if (currentCol == x / 2 - 1)
- {
- currentRow++;
- currentCol++;
- break;
- }
- }
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow--;
- currentCol++;
- if (currentRow < 0)
- {
- currentRow++;
- currentCol--;
- break;
- }
- }
- while (true)
- {
- matrix[currentRow, currentCol] = 1;
- currentRow++;
- currentCol++;
- if (currentCol == width)
- {
- break;
- }
- }
- //printing
- for (int row = 0; row < width; row++)
- {
- for (int col = 0; col < width; col++)
- {
- if (matrix[row, col] == 0)
- {
- Console.Write('.');
- }
- else if (matrix[row, col] == 1)
- {
- Console.Write('*');
- }
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement