//这是我目前写的代码,大家看看哪里有问题啊,我知道我写的不好,希望大家能指正啊
#include<iostream>
using namespace std;
class Student
{
public:
void shuru();
static int GetNum();
static float GetAvg();
private:
char Stu_Name[5];
float Eng_Score;
static int Stu_Num;
static float Score_Avg;
};
void Student::shuru()
{
cout << "输入学生姓名以及英语成绩" << endl;
cin >> Stu_Name>> Eng_Score;
float sum=Stu_Num*Score_Avg+Eng_Score;
Stu_Num++;
Score_Avg = sum / Stu_Num;
}
int Student::GetNum()
{
return Stu_Num;
}
float Student::GetAvg()
{
return Score_Avg;
}
int Student::Stu_Num = 0;
float Student::Score_Avg=0.0;
void main()
{
int count;
float av;
Student stu[5];
for(int i=0;i<5;++i)
stu[i].shuru();
count = stu[1].GetNum();
cout << "总人数是:" << count << endl;
av = stu[1].GetAvg();
cout << "平均分是:" << av << endl;
//system("pause");
}