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