Advertisement
Guest User

с12

a guest
Nov 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. static int[,] FillingArray(int n)
  2.         {
  3.             int[,] array = new int[n, n];
  4.             for (int i = 0; i < n; i++)
  5.                 for (int j = 0; j < n; j++)
  6.                 {
  7.                     array[i, j] = (i + j + 1)<=n? (i + j + 1) : 0;
  8.                 }
  9.             return array;
  10.         }
  11.  
  12.         static void ShowArray(int[,] array)
  13.         {
  14.             for (int i = 0; i < array.GetLength(0); i++)
  15.             {
  16.                 for (int j = 0; j < array.GetLength(1); j++)
  17.                 {
  18.                     Console.Write("{0,-3}", array[i, j]);
  19.                 }
  20.                 Console.WriteLine();
  21.             }
  22.         }
  23.         static void Main()
  24.         {
  25.             int[,] array = FillingArray(10);
  26.             ShowArray(array);
  27.             Console.ReadKey();
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement