回复 楼主 宇智波曌
我做了一下,不知道是不是你想要的,仅供参考。
#include"iostream"
#define MaxSize 100
using namespace std;
class Student
{
private:
float score[4];
float avge;
float sum;
public:
void set_score()
{
int i;
cout<<"please input the score :"<<endl;
for(i=0;i<4;i++)
cin>>score[i];
}
void calculate()
{
int i;
sum=0;
for(i=0;i<4;i++)
sum+=score[i];
avge=sum/4;
cout<<"总和是:"<<sum<<"平均值是:"<<avge<<endl;
for(i=0;i<4;i++)
if((score[i]>=0)&&(score[i]<60))
cout<<score[i]<<" ";
cout<<endl;
}
};
void main()
{
Student student[MaxSize];
int n,i;
cout<<"请输入学生人数:"<<endl;
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"请输入第"<<i<<"个学生的成绩:"<<endl;
student[i].set_score();
student[i].calculate();
}
}