using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bt_7
{
class Program
{
static int[,] a;
static int h, c;
static void nhap()
{
do
{
Console.Write("nhap h="); h = int.Parse(Console.ReadLine());
Console.Write("nhap c="); c = int.Parse(Console.ReadLine());
} while (h != c);
a = new int[h, c];
for (int i = 0; i < h; i++)
for (int j = 0; j < c; j++)
{
Console.Write("a[{0},{1}]=", i, j);
a[i, j] = int.Parse(Console.ReadLine());
}
}
static void hien()
{
for (int i = 0; i < h; i++)
{
for (int j = 0; j < c; j++)
Console.Write(a[i, j] + "\t");
Console.WriteLine();
}
}
static void duongcheochinh()
{
Console.WriteLine("cac phan tu ten duong cheo chinh la:");
for (int i = 0; i < h; i++)
for (int j = 0; j < c; j++)
if (i == j)
Console.Write(a[i, j] + "\t");
}
static void duongcheophu()
{
Console.WriteLine("\ncac phan tu tren duong cheo phu la:");
for (int i = c-1; i >=0; i--)
for (int j = 0; j <c; j++)
{
if(i+j==c-1)
Console.Write(a[i, j]+"\t");
}
}
static void Main(string[] args)
{
nhap();
hien();
duongcheochinh();
duongcheophu();
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace bt_7
{
class Program
{
static int[,] a;
static int h, c;
static void nhap()
{
do
{
Console.Write("nhap h="); h = int.Parse(Console.ReadLine());
Console.Write("nhap c="); c = int.Parse(Console.ReadLine());
} while (h != c);
a = new int[h, c];
for (int i = 0; i < h; i++)
for (int j = 0; j < c; j++)
{
Console.Write("a[{0},{1}]=", i, j);
a[i, j] = int.Parse(Console.ReadLine());
}
}
static void hien()
{
for (int i = 0; i < h; i++)
{
for (int j = 0; j < c; j++)
Console.Write(a[i, j] + "\t");
Console.WriteLine();
}
}
static void duongcheochinh()
{
Console.WriteLine("cac phan tu ten duong cheo chinh la:");
for (int i = 0; i < h; i++)
for (int j = 0; j < c; j++)
if (i == j)
Console.Write(a[i, j] + "\t");
}
static void duongcheophu()
{
Console.WriteLine("\ncac phan tu tren duong cheo phu la:");
for (int i = c-1; i >=0; i--)
for (int j = 0; j <c; j++)
{
if(i+j==c-1)
Console.Write(a[i, j]+"\t");
}
}
static void Main(string[] args)
{
nhap();
hien();
duongcheochinh();
duongcheophu();
Console.ReadKey();
}
}
}