Advertisement
quanpaste

Paste

Apr 8th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BaitapKteam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Note: Windows 10: U don't need to change the console setting, If u are using Windows 7 or older google it
  14.             Console.OutputEncoding = Encoding.Unicode;
  15.             #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.
  16.             //Console.WriteLine("Hello HowKteam – Free Education");
  17.             #endregion
  18.  
  19.             #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ữ
  20.             ////Cach 1: Lazy
  21.             //Console.WriteLine($"Chào mừng {Console.ReadLine()} đến với Howkteam");
  22.             ////Cach 2: Beginer friendly
  23.             //string a = Console.ReadLine();
  24.             //Console.WriteLine("Chào mừng {0} đến với Howkteam", a);
  25.             #endregion
  26.  
  27.             #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:
  28.             ////Cach 1: Lazy Cach con lai giong bai tren
  29.             //Console.WriteLine($"Số {Console.ReadLine()}, Số {Console.ReadLine()} và Số {Console.ReadLine()}");
  30.             #endregion
  31.  
  32.             #region Bai 4 Tạo một biến kiểu dữ liệu int khởi tạo giá trị bằng 90
  33.             //int a = 90;
  34.             #endregion
  35.  
  36.             #region Bai 5 Tạo một biến kiểu dữ liệu bool không khởi tạo dữ liệu
  37.             //bool isA;
  38.             #endregion
  39.  
  40.             #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.
  41.             //int sixA = 90;
  42.             //int sixB = sixA;
  43.             #endregion
  44.  
  45.             #region Bai 7
  46.             //int sevenA = 90;
  47.             //int sevenC = sevenA;
  48.             //bool sevenB = sevenA > sevenC;
  49.             #endregion
  50.  
  51.             #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
  52.             //bool isEight;
  53.             //Console.WriteLine(isEight);
  54.             #endregion
  55.  
  56.             #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:
  57.             //double a = 0, b = 0;
  58.             //bool isA = double.TryParse(Console.ReadLine(), out a);
  59.             //bool isB = double.TryParse(Console.ReadLine(), out b);
  60.             //if(isA && isB)
  61.             //    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));
  62.             //else
  63.             //    Console.WriteLine("Invalid");
  64.             #endregion
  65.  
  66.             #region Bai 10
  67.             //int a, b;
  68.             //if (int.TryParse(Console.ReadLine(), out a) && int.TryParse(Console.ReadLine(), out b))
  69.             //    Console.WriteLine($"{a > b} {a < b} {a >= b} {a <= b} {a == b} {a != b}");
  70.             //else
  71.             //    Console.WriteLine("Invalid!");
  72.             #endregion
  73.  
  74.             #region Bai 11:
  75.             //int a, b;
  76.             //if (int.TryParse(Console.ReadLine(), out a) && int.TryParse(Console.ReadLine(), out b))
  77.             //{
  78.             //    //Else if
  79.             //    if (a > b)
  80.             //        Console.WriteLine("a lớn hơn b");
  81.             //    else if (a < b)
  82.             //        Console.WriteLine("a nhỏ hơn b");
  83.             //    else
  84.             //        Console.WriteLine("a bằng b");
  85.             //    //Swich case
  86.  
  87.             //    int c = a - b;
  88.             //    switch (c)
  89.             //    {
  90.             //        case object d when ( a > b):
  91.             //            Console.WriteLine("a lớn hơn b");
  92.             //            break;
  93.             //        case object d when (a < b):
  94.             //            Console.WriteLine("a nhỏ hơn b");
  95.             //            break;
  96.             //        default:
  97.             //            Console.WriteLine("a bằng b");
  98.             //            break;
  99.             //    }
  100.  
  101.             //}
  102.  
  103.             #endregion
  104.  
  105.             #region Bai 12:
  106.             //double a, b;
  107.             //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b))
  108.             //{
  109.             //    if (a != 0)
  110.             //        Console.WriteLine((-a)/b);
  111.             //    else
  112.             //        Console.WriteLine("Invalid");
  113.             //}
  114.             //else
  115.             //{
  116.             //    Console.WriteLine("Invalid Number");
  117.             //}
  118.             #endregion
  119.  
  120.             #region Bai 13:
  121.             //double a, b, c, del;
  122.             //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b) && double.TryParse(Console.ReadLine(), out c))
  123.             //{
  124.             //    if (a != 0)
  125.             //    {
  126.             //        del = Math.Pow(b, 2) - 4 * a * c;
  127.             //        switch (new int())
  128.             //        {
  129.             //            case object buffer when (del > 0):
  130.             //                Console.WriteLine($"x1: {(-b + Math.Sqrt(del)) / 2} x2: {(-b - Math.Sqrt(del)) / 2}");
  131.             //                break;
  132.             //            case object buffer when (del == 0):
  133.             //                Console.WriteLine($"x: {(-b) / 2}");
  134.             //                break;
  135.             //            default:
  136.             //                Console.WriteLine($"Invalid in real number! I am  a secondary student so no implex oK!");
  137.             //                break;
  138.             //        }
  139.             //    }
  140.             //    else
  141.             //    {
  142.             //        Console.WriteLine("fx-570VN: MathError");
  143.             //    }
  144.             //}
  145.             //else
  146.             //{
  147.             //    Console.WriteLine("Invalid");
  148.             //}
  149.             #endregion
  150.  
  151.             #region Bai 14:
  152.             //double a, b, c;
  153.             //if (double.TryParse(Console.ReadLine(), out a) && double.TryParse(Console.ReadLine(), out b) && double.TryParse(Console.ReadLine(), out c))
  154.             //{
  155.             //    if (a > b && a > c)
  156.             //        Console.WriteLine(a);
  157.             //    else if (b > a && b > c)
  158.             //        Console.WriteLine(b);
  159.             //    else
  160.             //        Console.WriteLine(c);
  161.  
  162.             //    switch (a)
  163.             //    {
  164.             //        case Object buffer when (a > b && a > c):
  165.             //            Console.WriteLine(a);
  166.             //            break;
  167.             //        case object buffer when (b > a && b > c):
  168.             //            Console.WriteLine(b);
  169.             //            break;
  170.             //        default:
  171.             //            Console.WriteLine(c);
  172.             //            break;
  173.             //    }
  174.             //}
  175.             #endregion
  176.  
  177.             #region Bai 15:
  178.             //Method (Math only) in WikiHow.com
  179.             //On the webpage, no  way to input a Vietnamese string without string class or indexer support, so should change to
  180.             //dd/mm/yy or add string class to the task:
  181.  
  182.             string[] a = Console.ReadLine().Split(' ');
  183.             int day, month, year;
  184.             if (a.Length == 6)
  185.             {
  186.                 if (int.TryParse(a[1], out day) && int.TryParse(a[3], out month) && int.TryParse(a[5], out year))
  187.                 {
  188.                     DateTime dt = new DateTime(year, month, day);
  189.                     Console.WriteLine(dt.DayOfWeek);
  190.                 }
  191.             }
  192.             else
  193.             {
  194.                 Console.WriteLine("Invalid Format");
  195.             }
  196.  
  197.             #endregion
  198.             Console.ReadLine();
  199.         }
  200.     }
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement