using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Bai_2 { internal class Program { class Person { public string hoten { get; set; } public string gioitinh { get; set; } public int age { get; set; } public Person() { hoten = ""; gioitinh = ""; age = 0; } public Person(string ht, string gt, int a) { hoten = ht; gioitinh = gt; age = a; } public virtual void Input() { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("Vao ho ten: "); hoten = Console.ReadLine(); Console.WriteLine("Vao gioi tinh: "); gioitinh = Console.ReadLine(); Console.WriteLine("Vao tuoi: "); age = Int32.Parse(Console.ReadLine()); } public virtual void Show() { Console.Write("{0,-20}{1,-10}{2,-30}", hoten, gioitinh, age); } } class CongNhan : Person { public string tencty { get; set; } public int hesoluong { get; set; } public CongNhan() : base() { tencty = ""; hesoluong = 0; } public CongNhan(string ht, string gt, int a, string tcty, int hsl) : base(ht, gt, a) { tencty = tcty; hesoluong = hsl; } public override void Input() { base.Input(); Console.Write("Vao ten cty: "); tencty = Console.ReadLine(); Console.Write("Vao he so luong: "); hesoluong = Int32.Parse(Console.ReadLine()); } public double ThuNhap() { return hesoluong * 85000; } public override void Show() { base.Show(); Console.WriteLine("{0,-10}{1,-20}", tencty, ThuNhap()); } } class Program1 { static void Main(string[] args) { List DSCN = new List(); int n; Console.Write("Nhap so luong cong nhan: "); n = int.Parse(Console.ReadLine()); Console.WriteLine("\n======Nhap danh sach cong nhan ======"); for(int i = 0;i < n; i++) { Console.WriteLine("Nhap sinh vien thu {0}: ", i + 1); CongNhan cn = new CongNhan(); cn.Input(); DSCN.Add(cn); } Console.WriteLine("\n=====Danh sach cong nhan vua nhap la======"); Console.WriteLine("{0,-20}{1,-10}{2,-30}{3,-10}", "Hoten", "Gioi tinh", "Tuoi", "Ten cong ty", "He so luong", "Thu nhap"); foreach (CongNhan cn in DSCN) { cn.Show(); } double maxHeso = 0; foreach (CongNhan cn in DSCN) { if (cn.hesoluong > maxHeso) maxHeso = cn.hesoluong; } Console.WriteLine("\n=== Cong nhan co he so luong cao nhat ==="); Console.WriteLine("{0,-20}{1,-10}{2,-10}{3,-20}{4,-15}{5,-15}", "Hoten", "Gioi tinh", "Tuoi", "Ten cong ty", "He so luong", "Thu nhap"); foreach (CongNhan cn in DSCN) { if (cn.hesoluong == maxHeso) cn.Show(); Console.ReadLine(); } } } } }