#include <iostream>
using namespace std;
class Student
{
private:
	int num;
	int age;
	float score;
	static float sum;                             //声明静态数据成员
	static int count;                             //声明静态数据成员
public:
	Student(int n,int a,float s);                    //声明有参构造函数
	void total();
	static float average();                        //声明静态成员函数
};
int main()
{
	Student t[3]=                              //定义对象数组t，并为其初始化
	{
		Student(500,18,80),
		Student(501,19,81),
		Student(502,20,82),
	};
		int n;
		cout<<"please input the number of student"<<endl;
		cin>>n;
		for(int i=0;i<n;i++)
			t[i].total();
			cout<<"the average score of "<<n<<" student is "<<Student::average()<<endl;
                                              //调用静态成员函数
		return 0;
}

float Student::sum=0;                             //对静态数据成员赋初值
int Student::count=0;                             //对静态数据成员赋初值
Student::Student(int n,int a,float s)                  //定义构造函数
{
	num=n;
	age=a;
	score=s;
}
void Student::total()                            
{
	sum=sum+score;
	count++;
}
float Student::average()                            //定义静态成员函数
{
	return(sum/count);
}

