MuffinMonster

Class Task 48#

Feb 18th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Insert(int[,] arr)
  11.         {
  12.             for (int i = 0; i < arr.GetLength(0); i++)
  13.             {
  14.                 for (int j = 0; j < arr.GetLength(1); j++)
  15.                 {
  16.                     Console.WriteLine("Enter a num for position " + i + " / " + j);
  17.                     arr[i, j] = int.Parse(Console.ReadLine());
  18.                 }
  19.             }
  20.         }
  21.         static bool Check(int[,] arr)
  22.         {
  23.             bool ok = true;
  24.             for (int i = 0; i < arr.GetLength(0) / 2; i++)
  25.             {
  26.                 for (int j = 0; j < arr.GetLength(1) / 2; j++)
  27.                 {
  28.                     if ((arr[i, j] != arr[arr.GetLength(0) - i - 1, j]) || (arr[i, j] != arr[i, arr.GetLength(1) - j - 1]) || (arr[i, j] != arr[arr.GetLength(0) - i - 1, arr.GetLength(1) - j - 1]))
  29.                     {
  30.                         ok = false;
  31.                     }
  32.                 }
  33.             }
  34.             return ok;
  35.         }
  36.         static void Main(string[] args)
  37.         {
  38.             int[,] Arr = new int[4, 4];
  39.             Insert(Arr);
  40.             bool ok = Check(Arr);
  41.             Console.Clear();
  42.             for (int i = 0; i < 4; i++)
  43.             {
  44.                 for (int j = 0; j < 4; j++)
  45.                 {
  46.                     Console.Write(Arr[i, j] + " ");
  47.                 }
  48.                 Console.WriteLine();
  49.             }
  50.             Console.WriteLine();
  51.             Console.WriteLine(ok);
  52.             Console.ReadKey();
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment