static void Main(string[] args)
Console.WriteLine("---> Phần 1. Bài 6. Bài toán tính cạnh và góc của một tam giác <---");
int canh_a, canh_b, goc_e;
Console.WriteLine("Nhập cạnh thứ nhất AB là: ");
Console.WriteLine("Nhập cạnh thứ hai AC là: ");
Console.WriteLine("Nhập góc giữa 2 cạnh AB và AC: ");
gocAbc = Console.ReadLine();
if (int.TryParse(ab, out canh_a) == false || int.TryParse(ac, out canh_b) == false || int.TryParse(gocAbc, out goc_e) == false || canh_a <= 0 || canh_b <= 0 || goc_e <= 0 || goc_e >= 180)
Console.WriteLine("Cạnh và góc phải là số nguyên, góc không được bằng hoặc hơn 180 độ. Vui lòng nhập lại");
double canh_c = Math.Sqrt(Math.Pow(canh_a, 2) + Math.Pow(canh_b, 2) - 2 * canh_a * canh_b * Math.Cos((goc_e * (Math.PI)) / 180));
Console.WriteLine("Số đo cạnh còn lại là BC: " + Math.Round(canh_c));
double y = Math.Acos(((Math.Pow(canh_a, 2) + Math.Pow(canh_c, 2) - Math.Pow(canh_b, 2)) / (2 * canh_a * canh_c)));
double gocABC = y * (180 / Math.PI);
Console.WriteLine("Số đo góc ABC là: " + Math.Round(gocABC));
double z = Math.Acos(((Math.Pow(canh_b, 2) + Math.Pow(canh_c, 2) - Math.Pow(canh_a, 2)) / (2 * canh_b * canh_c)));
double gocACB = z * (180 / Math.PI);
Console.WriteLine("Số đo góc còn lại là: " + Math.Round(gocACB));
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("Bạn có muốn làm lại bài tập 1 không! - (y = Yes) || (n = No)");
Console.Write("Moi Nhap: ");
string choiLai = Console.ReadLine();
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
public static void BaiToanMaTran()
Console.WriteLine("---> Phần 4. Bài 6. Nhập vào 2 ma trận Amxn và Bnxp, tính kết quả của Cmxp = Amxn * Bnxp. <---");
Console.WriteLine("Nhập vào số hàng ma trận A:");
hang = Console.ReadLine();
Console.WriteLine("Nhập vào số cột ma trận A:");
dong = Console.ReadLine();
if (int.TryParse(hang, out m) == false || int.TryParse(dong, out n) == false)
Console.WriteLine("Chỉ nhận số nguyên. Vui lòng nhập lại.");
Console.WriteLine("Số hàng và cột phải là số nguyên lớn hơn 0. Vui lòng nhập lại. ");
Console.WriteLine("Ma trận A là: ");
Console.WriteLine("Nhập vào số hàng ma trận B:");
hang = Console.ReadLine();
Console.WriteLine("Nhập vào số cột ma trận B:");
dong = Console.ReadLine();
if (int.TryParse(hang, out m) == false || int.TryParse(dong, out n) == false)
Console.WriteLine("Chỉ nhận số nguyên. Vui lòng nhập lại.");
Console.WriteLine("Số hàng và cột phải là số nguyên lớn hơn 0. Vui lòng nhập lại. ");
Console.WriteLine("Ma trận B là: ");
Console.WriteLine("Kết quả của phép nhân ma trận: Cmxp = Amxn * Bnxp");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("Bạn có muốn làm lại bài tập 2 không! - (y = Yes) || (n = No)");
Console.Write("Moi Nhap: ");
string choiLai = Console.ReadLine();
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.WriteLine("Cám ơn bạn đã làm bài tập!");
public static void ReadMatrix(out int[,] M, int row, int col)
for (int i = 0; i < row; i++)
for (int j = 0; j < col; j++)
Console.Write("Phần tử [{0},{1}]:", i, j);
string num = Console.ReadLine();
if (int.TryParse(num, out M[i, j]) == false)
Console.WriteLine("Chỉ nhận dạng số. Vui lòng nhập lại");
public static void PrintMatrix(int[,] M)
for (int i = 0; i < M.GetLength(0); i++)
for (int j = 0; j < M.GetLength(1); j++)
Console.Write("{0} ", M[i, j]);
public static void MulMatrix(int[,] a, int[,] b, out int[,] c)
c = new int[a.GetLength(0), b.GetLength(1)];
if (a.GetLength(1) != b.GetLength(0))
Console.WriteLine("Số cột của Ma trận A không bằng số hàng của Ma trận B nên không nhân được !");
for (int i = 0; i < a.GetLength(0); i++)
for (int j = 0; j < b.GetLength(1); j++)
for (int k = 0; k < b.GetLength(0); k++)
c[i, j] = c[i, j] + a[i, k] * b[k, j];