Advertisement
Ochkasty_Dino

Practicum7-IV-5

Oct 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp2
  8. {
  9.     class Program
  10.     {
  11.        
  12.         static void Main()
  13.         {
  14.             int k=0;
  15.             Console.Write("Please enter the n=");
  16.             int n = int.Parse(Console.ReadLine());
  17.             int[,] a=new int [n,n];
  18.             for(int i=0;i<a.GetLength(0);i++)
  19.             {
  20.                 for (int j = 0; j < a.GetLength(1); j++)
  21.                 {
  22.                     a[i, j] = int.Parse(Console.ReadLine());
  23.                 }
  24.             }
  25.             int min = a.GetLength(0) < a.GetLength(1) ? a.GetLength(0) : a.GetLength(1);
  26.             int z = 0, l = a.GetLength(0) - 1;
  27.             for (int i = min - 1; i >= 0; i--, z++, l--)
  28.             {
  29.                 k = a[i, i];
  30.                 a[i, i] = a[l, z];
  31.                 a[l, z] = k;
  32.             }
  33.             for (int i = 0; i < a.GetLength(0); i++)
  34.             {
  35.                 for (int j = 0; j < a.GetLength(1); j++)
  36.                     Console.Write(a[i, j] + "\t");
  37.                 Console.WriteLine();
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement