usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
namespacestatictest
{
classStudent
{
intno;
stringname;
intdeg1;
intdeg2;
intdeg3;
staticintsum1=0;
staticintsum2=0;
staticintsum3=0;
staticintsn=0;
publicStudent(intn,stringna,intd1,intd2,intd3)
{
no=n;name=na;
deg1=d1;deg2=d2;deg3=d3;
sn++;
}
publicvoiddisp()
{//(double)(deg1+deg2+deg3)/3
Console.WriteLine("学号:{0}姓名:{1}语文:{2}数学:{3}英语:{4}平均分:{5:f}",no,name,deg1,deg2,deg3,(double)(deg1+deg2+deg3)/3);
}
publicstaticdoubleavg1(){return(double)sum1/sn;}
publicstaticdoubleavg2(){return(double)sum2/sn;}
publicstaticdoubleavg3(){return(double)sum3/sn;}
};
classprogram
{
staticvoidMain(string[]args)
{
Students1=newStudent(1,"王华",67,89,90);
Students2=newStudent(1,"黎明",68,90,91);
Students3=newStudent(1,"张兵",69,89,92);
Students4=newStudent(1,"王超",70,92,93);
Console.WriteLine("输出结果");
s1.disp();s2.disp();s3.disp();s4.disp();
Console.WriteLine("语文平均分:{0}数学平均分:{1}英语平均分:{2}",Student.avg1(),Student.avg2(),Student.avg3());
Console.ReadKey();
}
}
}