You are on page 1of 10

using System;

namespace test2
{
class Program
{
static void Main(string[] args)
{
BT5();
}

//Bai tap 5
static void BT5()
{
Console.WriteLine("Nhap mot so tu 0-9");
int a = int.Parse(Console.ReadLine());
switch (a)
{
case 0: Console.WriteLine(" zero");break;
case 1: Console.WriteLine(" one"); break;
case 2: Console.WriteLine(" two"); break;
case 3: Console.WriteLine(" three"); break;
case 4: Console.WriteLine(" four"); break;
case 5: Console.WriteLine(" five"); break;
case 6: Console.WriteLine(" six"); break;
case 7: Console.WriteLine(" seven"); break;
case 8: Console.WriteLine(" eight"); break;
case 9: Console.WriteLine(" night"); break;
default: Console.WriteLine("error");break;
}

// Bai tap 4
static void BT4()
{
// Nhap 3 so thuc
Console.WriteLine("Nhap a");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap b");
double b = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap c");
double c = double.Parse(Console.ReadLine());
if (a > b && a > c)
{
if (b > c)
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", a, b, c);
else
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", a, c, b);

}
if (b > a && b > c)
{
if (a > c)
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", b, a, c);
else
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", b, c, a);

}
if (c > a && c > b)
{
if (a > b)
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", c, a, b);
else
Console.WriteLine("Thu tu giam dan {0}, {1}, {2}", c, b, a);
}

//Bai tap tai lop 3


static void BT3()
{
// Nhap 3 so thuc
Console.WriteLine("Nhap a");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap b");
double b = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap c");
double c = double.Parse(Console.ReadLine());

if (a > b)
{
//a > b > c
if (a > c)
{
Console.WriteLine("So lon nhat la: " + a);
}
//a > b && a < c
else
{
Console.WriteLine("So lon nhat la: " + c);

}
}

//a < b
else
{
// a < b < c
if (b<c)
{
Console.WriteLine("So lon nhat la: " + c);

//a < b && b > c


else
{
Console.WriteLine("So lon nhat la: " + b); ;
}

// Bai tap tai lop 2


static void BT2()
{
// Nhap 3 so thuc
Console.WriteLine("Nhap a");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap b");
double b = double.Parse(Console.ReadLine());
Console.WriteLine("Nhap c");
double c = double.Parse(Console.ReadLine());

// Thop A +
if (a > 0)
{
//a+ b+
if (b > 0)
{
//a+ b+ c+
if (c > 0)
{
Console.WriteLine("Dau duong");
}
//a+ b+ c-
else
{
Console.WriteLine("Dau am");
}
}
//a+ b-
else
{
//a+ b- c+
if (c > 0)
{
Console.WriteLine("Dau am");
}
//a+ b- c-
else
{
Console.WriteLine("Dau duong");
}
}
}
//a-
else
{
//a- b+
if (b > 0)
{
//a- b+ c+
if (c > 0)
{
Console.WriteLine("Dau am");
}
//a- b+ c-
else
{
Console.WriteLine("Dau duong");
}
}
//a- b-
else
{
//a- b- c+
if (c > 0)
{
Console.WriteLine("Dau duong");
}
//a- b- c-
else
{
Console.WriteLine("Dau am");
}
}
}

// Bài tập tại lớp 1


static void BT1()
{
//Nhập 2 số
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());

// Kiểm tra điều kiện


if (a > b)
{
// Thực hiện đổi giá trị
int tg = a;
a = b;
b = tg;
}

//In ra màn hình


Console.WriteLine(a + " " + b);
}
// bài học
static void BaiHoc()
{
//Console.WriteLine("Nhập vào tháng: ");
//int thang = int.Parse(Console.ReadLine());

//switch (thang)
//{
// case 1:
// case 3:
// case 5:
// case 7:
// case 8:
// case 10:
// case 12:
// Console.WriteLine("Tháng {0} có {1} ngày.", thang, 31);
// break;

// case 4:
// case 6:
// case 9:
// case 11:
// Console.WriteLine("Tháng {0} có {1} ngày.", thang, 30);
// break;

// case 2:
// Console.WriteLine("Tháng {0} có 28 || 29 ngày.", thang);
// break;

// default:
// break;
//}

//Console.WriteLine("Nhập vào thứ: ");


//int thu = int.Parse(Console.ReadLine());

//switch (thu)
//{
// case 2:
// Console.WriteLine("Monday");
// break;
// case 3:
// Console.WriteLine("Tuesday");
// break;
// case 4:
// Console.WriteLine("Wednesday");
// break;
// case 5:
// Console.WriteLine("Thursday");
// break;
// case 6:
// Console.WriteLine("Friday");
// //...

// break;
// case 7:
// Console.WriteLine("Saturday");
// break;
// case 1:
// Console.WriteLine("Sunday");
// break;

// // Nếu như không rơi vào các case ở trên thì làm default
// default:
// Console.WriteLine("Bạn đã nhập sai");

// //Ngưng chương trình và thoát ra khỏi lệnh switch


// break;
//}

//Giải phương trình bậc 1


// ax + b = 0

//Nhập a, b
//Console.WriteLine("Nhập số a: ");
//float a = float.Parse(Console.ReadLine());

//Console.WriteLine("Nhập số b: ");
//float b = float.Parse(Console.ReadLine());

////Xét trường hợp a = 0


//if (a == 0)
//{
// // nếu a = 0 thì xét tiếp b = 0 hoặc != 0
// if (b == 0)
// {
// // a == 0 và b == 0
// Console.WriteLine("Phương trình vô số nghiệm");
// }
// else
// {
// //a == 0 và b != 0
// Console.WriteLine("Phương trình vô nghiệm");
// }

//}
//// a != 0
//else
//{
// // nếu a != 0 thì in ra biến x
// float x = -b / a;
// Console.WriteLine("Nghiệm của phương trình là: x = {0}", x);
//}

//Console.Write("Nhập vào 1 ký tự: ");

//char ch = char.Parse(Console.ReadLine());

////kiểm tra ký tự nhập vào


//if (ch == 'A' || ch == 'a')
//{
// Console.WriteLine("Nguyên âm [ei]");
//}else if (ch == 'E' || ch == 'e')
//{
// // ch không phải là A hoặc a
// Console.WriteLine("Nguyên âm [i:]");
//}

//Nếu có người yêu THÌ đi chơi Valungtung


// Nếu không có THÌ cầu mưa
//Console.WriteLine("Có người yêu chưa? (Y/N/C):");
//string tloi = Console.ReadLine();

//if ((tloi == "Y") || (tloi == "C"))


//{
// Console.WriteLine("Đi chơi Valungtung");
//}
//else
//{
// Console.WriteLine("Cầu mưa");
//}

//Console.WriteLine("Nhập vào số thứ 1: ");


//int so1 = int.Parse(Console.ReadLine());

//Console.WriteLine("Nhập vào số thứ 2: ");


//int so2 = int.Parse(Console.ReadLine());

//if (so1 == so2)


//{
// Console.WriteLine("Hai số bằng nhau");
//}
//else
//{
// //Hai số không bằng nhau
// if (so1 > so2)
// {
// Console.WriteLine("Số thứ nhất lớn hơn");
// }
// else
// {
// // 2 số ko bằng nhau
// // số 2 lớn hơn số 1
// Console.WriteLine("Số thứ 2 lớn hơn");
// }
//}

//Kiểm tra số n là chẵn hay lẻ


// Kiểm tra phần dư khi % 2
//if (n % 2 == 0)
//{
// Console.WriteLine("Số chẵn");
//}
//else
//{
// Console.WriteLine("Số lẻ");
//}

//lệnh nếu đúng


//Console.WriteLine("Hello World!");
}
}
}

You might also like