コード例 #1
0
        public Sinhvien nhap()
        {
            Sinhvien sv   = new Sinhvien();
            double   tong = 0;

            Console.WriteLine("so mon hoc:");
            sv.monhoc.Somon = int.Parse(Console.ReadLine());
            Console.WriteLine("nhap ten sv:");
            sv.Hoten1 = Console.ReadLine();
            Console.WriteLine("nhap nam sinh :");
            sv.Namsinh1 = int.Parse(Console.ReadLine());
            Console.WriteLine("nhap diem cac mon :");
            for (int i = 1; i <= sv.monhoc.Somon; i++)
            {
                Console.WriteLine("Mon " + i + ":");
                sv.monhoc[i] = double.Parse(Console.ReadLine());
                tong         = tong + sv.monhoc[i];
            }
            sv.monhoc.DiemTB1 = (tong / sv.monhoc.Somon);
            return(sv);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int soSV;

            Console.WriteLine("nhap so sv:");
            soSV = int.Parse(Console.ReadLine());
            Sinhvien[] SV = new Sinhvien[soSV];
            for (int i = 0; i < soSV; i++)
            {
                SV[i] = new Sinhvien();
                SV[i] = SV[i].nhap();
            }
            int luanan = 0, totnghiep = 0, thilai = 0;

            for (int i = 0; i < soSV; i++)
            {
                if (SV[i].monhoc.DiemTB1 > 7)
                {
                    int dem = 0;
                    for (int j = 1; j <= SV[i].monhoc.Somon; j++)
                    {
                        if (SV[i].monhoc[j] >= 5)
                        {
                            dem++;
                        }
                    }
                    if (dem == SV[i].monhoc.Somon)
                    {
                        luanan++;
                    }
                    else
                    {
                        thilai++;
                    }
                }
                if (SV[i].monhoc.DiemTB1 <= 7 && SV[i].monhoc.DiemTB1 >= 5)
                {
                    int dem = 0;
                    for (int j = 1; j <= SV[i].monhoc.Somon; j++)
                    {
                        if (SV[i].monhoc[j] >= 5)
                        {
                            dem++;
                        }
                    }
                    if (dem == SV[i].monhoc.Somon)
                    {
                        totnghiep++;
                    }
                    else
                    {
                        thilai++;
                    }
                }
                if (SV[i].monhoc.DiemTB1 < 5)
                {
                    thilai++;
                }
            }
            Console.WriteLine("So SV lam luan an la:" + luanan);
            Console.WriteLine("So SV tot nghiep la:" + totnghiep);
            Console.WriteLine("So SV thi lai la:" + thilai);
            Console.ReadKey();
        }