云一网站建设,gta5购买房产网站正在建设,鲅鱼圈网站建设,龙岗菠菜网站建设题目#xff1a;有三名同学#xff0c;在一次考试中三科成绩分别如下表#xff0c;请输出三名同学的平均成绩#xff1a;
语文数学英语张三100100100李四9050100王五607080
#include iostream
#include string
/*考试成绩统计*/
using namespace std;cla…题目有三名同学在一次考试中三科成绩分别如下表请输出三名同学的平均成绩
语文数学英语张三100100100李四9050100王五607080
#include iostream
#include string
/*考试成绩统计*/
using namespace std;class Score {private :string id;int chinese;int english;int math;public :Score(string name, int score1, int score2, int score3) : id(name), chinese(score1), english(score2), math(score3) {}double getAvgScore(){return (chinese math english) / 3.0;}string getName() {return id;}
}; int main() {Score s1(张三, 100, 100, 100);Score s2(李四, 90, 50, 100);Score s3(王五, 60, 70, 80);cout s1.getName() 的平均成绩是 s1.getAvgScore() endl;cout s2.getName() 的平均成绩是 s2.getAvgScore() endl;cout s3.getName() 的平均成绩是 s3.getAvgScore() endl;return 0;
}