Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int count;
- if ((n / 2 & 1) == 1)
- {
- count = n / 4 + 1;
- }
- else
- {
- count = n / 4;
- }
- char[,] matrix = new char[n, n];
- for (int i = 0; i / 2 < count; i += 2)
- {
- // / up
- for (int x = n / 2 - 1, y = 0 + i; y < n / 2; x--, y++)
- {
- matrix[x, y] = '/';
- }
- // \ up
- for (int x = n / 2 - 1, y = n - 1 - i; y > n / 2 - 1; x--, y--)
- {
- matrix[x, y] = '\\';
- }
- // \ down
- for (int x = n / 2, y = 0 + i; y < n / 2; x++, y++)
- {
- matrix[x, y] = '\\';
- }
- // / down
- for (int x = n / 2, y = n - 1 - i; y > n / 2 - 1; x++, y--)
- {
- matrix[x, y] = '/';
- }
- }
- // dots
- for (int x = 0; x < n; x++)
- {
- for (int y = 0; y < n; y++)
- {
- if (matrix[x, y] == 0)
- {
- if (x == 0 || y == 0 || y == n - 1)
- {
- matrix[x, y] = '.';
- }
- else if (matrix[x - 1, y] == '.' || matrix[x, y - 1] == '.')
- {
- matrix[x, y] = '.';
- }
- else if (matrix[x, y - 1] == '/' && matrix[x, y + 1] == 0 && x > n / 2)
- {
- matrix[x, y] = '.';
- }
- }
- }
- }
- PrintMatrix(matrix, n);
- }
- private static void PrintMatrix(char[,] matrix, int n)
- {
- for (int x = 0; x < n; x++)
- {
- for (int y = 0; y < n; y++)
- {
- Console.Write(matrix[x,y]);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment