using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Test { class Program { static void Main(string[] args) { Random r = new Random(); int size = 10;// int.Parse(Console.ReadLine()); int[,] arrA = new int[size, size]; int[,] arrB = new int[size, size]; for (int w = 0; w < size; w++) for (int h = 0; h < size; h++) arrA[w, h] = r.Next(10); int a1 = 0; int b1 = 0; int a2 = 0; int b2 = 0; for (int w = 0; w < size; w++) for (int h = 0; h < size; h++) { int counter = 0; int i = w; int j = h; for (a1 = i + 1, b1 = j - 1; b1 < size && a1 >= 1; a1--, b1++) for (int k = b1; k + 1 < size; counter += arrA[a1 - 1, k + 1], k++) ; for (a2 = i + 1, b2 = j + 1; b2 < size && a2 < size; a2++, b2++) for (int k = b2; k < size; counter += arrA[a2, k], k++) ; arrB[i, j] = counter; } Console.WriteLine("Array A:"); for (int w = 0; w < size; w++) { for (int h = 0; h < size; h++) Console.Write(arrA[w, h].ToString() + " "); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("Array B:"); for (int w = 0; w < size; w++) { for (int h = 0; h < size; h++) Console.Write(arrB[w, h].ToString() + " "); Console.WriteLine(); } } } }