Advertisement
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;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main()
- {
- int k=0;
- Console.Write("Please enter the n=");
- int n = int.Parse(Console.ReadLine());
- int[,] a=new int [n,n];
- for(int i=0;i<a.GetLength(0);i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- a[i, j] = int.Parse(Console.ReadLine());
- }
- }
- int min = a.GetLength(0) < a.GetLength(1) ? a.GetLength(0) : a.GetLength(1);
- int z = 0, l = a.GetLength(0) - 1;
- for (int i = min - 1; i >= 0; i--, z++, l--)
- {
- k = a[i, i];
- a[i, i] = a[l, z];
- a[l, z] = k;
- }
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- Console.Write(a[i, j] + "\t");
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement