#include
#include
#define N 3 //学生人数设为3
class score //定义成绩类
{
private:
float score1,score2,score3; //三门成绩
public:
score() //构造函数
{
score1=score2=score3=0;
}
void inputscore(float sc1,float sc2,float sc3);//输入三门课成绩的函数
float getscore(int i); //获得想要学生某门课的成绩
void show(); //显示出三门课成绩
};
//以下为函数的实现过程
void score::inputscore(float sc1,float sc2,float sc3)
{
score1=sc1;
score2=sc2;
score3=sc3;
}
float score::getscore(int i)
{
if(i==0)return score1;
else if(i==1)return score2;
else if(i==2)return score3;
}
void score::show()
{
cout<
}
//主函数
void main()
{
score student[N];
float s1,s2,s3;
cout<<"输入每个学生三门课的成绩(百分制):"<
for(int i=0;i
cin>>s1>>s2>>s3;
student[i].inputscore(s1,s2,s3);
}
cout<<"------------------------------------------"<
cout<
cout<<"第"< student[i].show();
}
//输出每门课程的不及格 及格 良好 优秀人数
cout<<"------------------------------------------------"<
{
int best=0,good=0,pass=0,fail=0;
for(i=0;i
if(student[i].getscore(j)>0&&student[i].getscore(j)<60)fail++;
else if(student[i].getscore(j)>=60&&student[i].getscore(j)<80)pass++;
else if(student[i].getscore(j)>=80&&student[i].getscore(j)<90)good++;
else if(student[i].getscore(j)>=90&&student[i].getscore(j)<100)best++;
}
cout<<"第"<
}
#include
#include
class student
{
public:
int math;
int chinese;
int english;
public:
student();
void addmark(int m,int c,int e);
void editmark(std::string subject,int mark);
int getmark(std::string subject);
};
student::student()
{
}
void student::addmark(int m, int c, int e)
{
math=m;
chinese=c;
english=e;
}
void student::editmark(std::string subject, int mark)
{
if(subject=="math")
math=mark;
else if(subject=="chinese")
chinese=mark;
else if(subject=="english")
english=mark;
}
int student::getmark(std::string subject)
{
int mark;
if(subject=="math")
mark=math;
else if(subject=="chinese")
mark=chinese;
else if(subject=="english")
mark=english;
return mark;
}
int main()
{
int mp=0,cp=0,ep=0;
student stu[10];
for(int i=0;i<10;i++)
{
int m,c,e;
//std::cin>>stu[i].math<
stu[i].addmark(m,c,e);
}
for(int i=0;i<10;i++)
{
if(stu[i].math>=60)
mp++;
if(stu[i].chinese>=60)
cp++;
if(stu[i].english>=60)
ep++;
}
std::cout<<"mp:"<
getchar();
}
调试可成 比较烂了 根据实际情况 弄个学生类指针 随便多少学生都可以了
#include
#include
using namespace std;
class student
{
private: char name[10];
char sex[5];
char number[7];
int age;
public: input();
print();
modify();
};
student a[3];
student::input()
{
cout<<"please input the student's name,sex,number and age:"<
{
cin>>a[i].name>>a[i].sex>>a[i].number>>a[i].age;
}
}
student::print()
{
cout<<"the student's message is:"<
cout<}
student::modify()
{
char str[5];
cout<<"please input the student's number who you want to modify:"<
for(int i=0;i<3;i++)
{
if(strcmp(str,a[i].number)==0)
{
cout<<"please input the new student's name,sex,number and age:"<
break;
}
}
}
void main()
{
student s;
s.input();
s.print();
s.modify();
s.print();
}
这个是在这里说得清楚的?