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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Fill1(int[,] arr)
- {
- int x = arr.GetLength(1) / 2;
- for (int i = 0; i <= arr.GetLength(0) / 2; i++)
- {
- arr[i, x] = 1;
- arr[i, arr.GetLength(1) - x - 1] = 1;
- arr[arr.GetLength(0) - i - 1, x] = 1;
- arr[arr.GetLength(0)-i-1,arr.GetLength(1)-x-1] = 1;
- x--;
- }
- }
- static void Fill2(int[,] arr)
- {
- int x = arr.GetLength(1) / 2 -1;
- for (int i = 0; i < arr.GetLength(0) / 2; i++)
- {
- arr[i, x] = 1;
- arr[i, arr.GetLength(1) - x - 1] = 1;
- arr[arr.GetLength(0) - i - 1, x] = 1;
- arr[arr.GetLength(0) - i - 1, arr.GetLength(1) - x - 1] = 1;
- x--;
- }
- }
- static void Main(string[] args)
- {
- int a = int.Parse(Console.ReadLine());
- int[,] arr = new int[a, a];
- if (a % 2 != 0)
- Fill1(arr);
- else
- Fill2(arr);
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write(arr[i, j]);
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment