大家好!帮忙改一下吧!运行时有误,但找不出来。“利用面向对象的思想设计一个班级学生成绩管理系统”
/*2.利用面向对象的思想设计一个班级学生成绩管理系统。要求:(1)要求存储学生的姓名、编号及各门成绩;
(2)可以对每个学生的各门成绩进行求和、求平均;
(3)能够实现对每门课程求和、求平均、求最高分和不及格的学生人数;
(4)能够实现成绩的打印和不及格学生的名单的打印。
我编的是三个学生三门课的*/
#include<iostream>
#include<string>
using namespace std;
class Stu{
public:
Stu(char* name1,char* number1)
{
name=name1;
number=number1;
}
void Sum_Ave()
{
sum=0;
ave=0;
cout<<"请输入学生三门课成绩:";
for(int i=0;i<3;++i)
cin>>score[i];
sum=score[1]+score[2]+score[3];
ave=sum/3;
cout<<"该学生的总分为:"<<sum<<"\t"<<"平均分为:"<<ave<<endl;
}
static void lesson(Stu &s1,Stu &s2,Stu &s3);
static void no(Stu &s1,Stu &s2,Stu &s3)
{
for(int i=0;i<3;i++)
{
if(s1.score[i]<60)
num[i]++;
if(s2.score[i]<60)
num[i]++;
if(s3.score[i]<60)
num[i]++;
cout<<"第"<<i<<"不及格学生的人数为:"<<num[i]<<endl;
}
}
private:
char* name;
char* number;
float* score;
float sum;
float ave;
static float* eversum;
static float* everave;
static float* high;
static int *num;
};
void Stu::lesson(Stu &s1,Stu &s2,Stu &s3)
{
for(int i=0;i<3;i++)
{ eversum[i]=s1.score[i]+s2.score[i]+s3.score[i];
everave[i]=eversum[i]/3;
}
for(int j=0;j<3;j++)
{ if(s1.score[j]>s2.score[j])
high[j]=s1.score[j];
high[j]=s2.score[j];
if(high[j]<s3.score[j])
high[j]=s3.score[j];
}
cout<<"第"<<i<<"课程的总分为:"<<eversum[i]<<endl;
cout<<"第"<<i<<"课程的平均分为:"<<everave[i]<<endl;
cout<<"第"<<j<<"课程的最高分为:"<<high[j]<<endl;
}
int* Stu::num=0;
float* Stu::eversum=0;
float* Stu::everave=0;
float* Stu::high=0;
int main()
{
Stu student1("lili","201112");
student1.Sum_Ave();
Stu student2("nana","201113");
student2.Sum_Ave();
Stu student3("dodo","201114");
student3.Sum_Ave();
Stu::lesson(student1,student2,student3);
Stu::no(student1,student2,student3);
return 0;
}