namespace csdn第一弹
{
class Student
{
int no;
int deg1;
int deg2;
int deg3;
string name;
static int sum1=0;
static int sum2=0;
static int sum3=0;
static int sn=0;
public Student(int n,string na,int d1,int d2,int d3)
{
no=n;
name=na;
deg1=d1;
deg2=d2;
deg3=d3;
sum1+=deg1;
sum2+=deg2;
sum3+=deg3;
sn++;
}
public void disp()
{
Console.WriteLine("学号:{0}姓名:{1}语文:{2}数学:{3}英语:{4}平均分:{5:f}",no,name,deg1,deg2,deg3,(double)(deg1+deg2+deg3)/3);
}
public static double avg1(){return (double)sum1/sn;}
public static double avg2(){return (double)sum2/sn;}
public static double avg3(){return (double)sum3/sn;}
};
class Program
{
static void Main(string[] args)
{
Student s1=new Student(1,"糕羊",100,100,100);
Student s2=new Student(2,"小鸟",99,99,98);
Student s3=new Student(3,"小手机",98,98,98);
Console.WriteLine("乖乖请输出结果鸭");
s1.disp();
s2.disp();
s3.disp();
Console.WriteLine("语文平均分:{0}数学平均分:{1}英语平均分:{2}",Student.avg1(),Student.avg2(),Student.avg3());
}
}
}