Пример #1
0
        static void Main(string[] args)
        {
            // 1.khai bao mang 5 hinh
            // 2.tim vi tri va gia tri cua hinh co
            // chu vi hoac dien tich lon nhat
            hinh[] Arr = new hinh[5];
            Arr[0] = new chuNhat();
            Arr[1] = new hinhTron(1);
            Arr[2] = new tamGiac(8, 9, 10);
            Arr[3] = new hinhVuong(9);
            Arr[4] = new chuNhat(6, 9);
            double MaxTamCv = Arr[0].hCv();
            double MaxTamDt = Arr[0].hDt();
            int    vtCv     = 0;
            int    vtDt     = 0;

            for (int i = 1; i < Arr.Length; i++)
            {
                if (MaxTamCv < Arr[i].hCv())
                {
                    MaxTamCv = Arr[i].hCv();
                    vtCv     = i;
                }
                if (MaxTamDt < Arr[i].hDt())
                {
                    MaxTamDt = Arr[i].hDt();
                    vtDt     = i;
                }
            }
            Console.WriteLine("dien tich tai {0} la max:{1}", vtDt, MaxTamDt);
            Console.WriteLine("chu vi tai {0} la max:{1}", vtCv, MaxTamCv);
        }
Пример #2
0
 public hinhVuong(hinhVuong hv) : base(hv)
 {
 }