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 BaitapKteam
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Note: Windows 10: U don't need to change the console setting, If u are using Windows 7 or older google it
- Console.OutputEncoding = Encoding.Unicode;
- #region Bai 1 Viết chương trình Console Application với ngôn ngữ C# in ra dòng chữ “Hello HowKteam – Free Education” lên màn hình Console.
- //Console.WriteLine("Hello HowKteam – Free Education");
- #endregion
- #region Bai 2 Viết chương trình nhập vào từ bàn phím một giá trị là tên và in ra màn hình Console dòng chữ
- ////Cach 1: Lazy
- //Console.WriteLine($"Chào mừng {Console.ReadLine()} đến với Howkteam");
- ////Cach 2: Beginer friendly
- //string a = Console.ReadLine();
- //Console.WriteLine("Chào mừng {0} đến với Howkteam", a);
- #endregion
- #region Bai 3 Viết chương trình nhập vào lần lượt 3 giá trị a b và c. Xuất ra ba giá trị đó theo định dạng như sau và phải sử dụng tham số của hàm Write hoặc WriteLine của Console:
- ////Cach 1: Lazy Cach con lai giong bai tren
- //Console.WriteLine($"Số {Console.ReadLine()}, Số {Console.ReadLine()} và Số {Console.ReadLine()}");
- #endregion
- #region Bai 4 Tạo một biến kiểu dữ liệu int khởi tạo giá trị bằng 90
- //int a = 90;
- #endregion
- #region Bai 5 Tạo một biến kiểu dữ liệu bool không khởi tạo dữ liệu
- //bool isA;
- #endregion
- #region Bai 6 Tạo một biến kiểu dữ liệu int khởi tạo giá trị bằng 90. Sau đó, tạo một biến kiểu dữ liệu int và gán giá trị khởi tạo bằng giá trị của biến được tạo ở ý trên.
- //int sixA = 90;
- //int sixB = sixA;
- #endregion
- #region Bai 7
- //int sevenA = 90;
- //int sevenC = sevenA;
- //bool sevenB = sevenA > sevenC;
- #endregion
- #region Bai 8 Tạo một biến kiểu dữ liệu bool không khởi tạo dữ liệu. Rồi xuất giá trị của biến đó ra màn hình
- //bool isEight;
- //Console.WriteLine(isEight);
- #endregion
- #region Bai 9 Nhập vào 2 giá trị kiểu số nguyên hoặc kiểu số thực a và b từ bàn phím. Xuất ra màn hình:
- //double a = 0, b = 0;
- //bool isA = double.TryParse(Console.ReadLine(), out a);
- //bool isB = double.TryParse(Console.ReadLine(), out b);
- //if(isA && isB)
- // Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", a+b, a-b,a*b,a/b,a%b,((a-(a%b))/b), ((a%b)/b));
- //else
- // Console.WriteLine("Invalid");
- #endregion
- #region Bai 10
- //int a, b;
- //if (int.TryParse(Console.ReadLine(), out a) && int.TryParse(Console.ReadLine(), out b))
- // Console.WriteLine($"{a > b} {a < b} {a >= b} {a <= b} {a == b} {a != b}");
- //else
- // Console.WriteLine("Invalid!");
- #endregion
- #region Bai 11:
- //int a, b;
- //if (int.TryParse(Console.ReadLine(), out a) && int.TryParse(Console.ReadLine(), out b))
- //{
- // //Else if
- // if (a > b)
- // Console.WriteLine("a lớn hơn b");
- // else if (a < b)
- // Console.WriteLine("a nhỏ hơn b");
- // else
- // Console.WriteLine("a bằng b");
- // //Swich case
- // int c = a - b;
- // switch (c)
- // {
- // case object d when ( a > b):
- // Console.WriteLine("a lớn hơn b");
- // break;
- // case object d when (a < b):
- // Console.WriteLine("a nhỏ hơn b");
- // break;
- // default:
- // Console.WriteLine("a bằng b");
- // break;
- // }
- //}
- #endregion
- #region Bai 12:
- //double a, b;
- //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b))
- //{
- // if (a != 0)
- // Console.WriteLine((-a)/b);
- // else
- // Console.WriteLine("Invalid");
- //}
- //else
- //{
- // Console.WriteLine("Invalid Number");
- //}
- #endregion
- #region Bai 13:
- //double a, b, c, del;
- //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b) && double.TryParse(Console.ReadLine(), out c))
- //{
- // if (a != 0)
- // {
- // del = Math.Pow(b, 2) - 4 * a * c;
- // switch (new int())
- // {
- // case object buffer when (del > 0):
- // Console.WriteLine($"x1: {(-b + Math.Sqrt(del)) / 2} x2: {(-b - Math.Sqrt(del)) / 2}");
- // break;
- // case object buffer when (del == 0):
- // Console.WriteLine($"x: {(-b) / 2}");
- // break;
- // default:
- // Console.WriteLine($"Invalid in real number! I am a secondary student so no implex oK!");
- // break;
- // }
- // }
- // else
- // {
- // Console.WriteLine("fx-570VN: MathError");
- // }
- //}
- //else
- //{
- // Console.WriteLine("Invalid");
- //}
- #endregion
- #region Bai 14:
- //double a, b, c;
- //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b) && double.TryParse(Console.ReadLine(), out c))
- //{
- // if (a > b && a > c)
- // Console.WriteLine(a);
- // else if (b > a && b > c)
- // Console.WriteLine(b);
- // else
- // Console.WriteLine(c);
- // switch (a)
- // {
- // case Object buffer when (a > b && a > c):
- // Console.WriteLine(a);
- // break;
- // case object buffer when (b > a && b > c):
- // Console.WriteLine(b);
- // break;
- // default:
- // Console.WriteLine(c);
- // break;
- // }
- //}
- #endregion
- #region Bai 15:
- //Method (Math only) in WikiHow.com
- //On the webpage, no way to input a Vietnamese string without string class or indexer support, so should change to
- //dd/mm/yy or add string class to the task:
- string[] a = Console.ReadLine().Split(' ');
- int day, month, year;
- if (a.Length == 6)
- {
- if (int.TryParse(a[1], out day) && int.TryParse(a[3], out month) && int.TryParse(a[5], out year))
- {
- DateTime dt = new DateTime(year, month, day);
- Console.WriteLine(dt.DayOfWeek);
- }
- }
- else
- {
- Console.WriteLine("Invalid Format");
- }
- #endregion
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement