博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
3.2.......
阅读量:37442 次
发布时间:2020-12-04 13:15:10

本文共 2752 字,大约阅读时间需要 9 分钟。

#include
#include
using namespace std;class studentsscore {public:studentsscore(){ student_nr = 2;}studentsscore(int students_count) { student_nr = student_count; } ~studentsscore() { cout << "Press any key to continue" << endl; } void input_student_name_and_score() { for (int student_id=0; students_id < student_nr; student_id++) { cout << "请输入学生姓名:"; cin >> name[students_id]; cout << "请输入科目a成绩:"; cin >> score[students_id][0]; cout << "请输入科目b成绩:"; cin >> score[students_id][1]; cout << "请输入科目c成绩:"; cin >> score[students_id][2]; } } void show_student_name_and_score() { for (int student_id=0; student_id < student_nr; students_id++) { cout << "姓名:" << name[student_id] << " 科目a成绩:" << score[student_id][0] << " 科目b成绩:" << score[student_id][1] << " 科目c成绩:" << score[student_id] [2]<<"\n"; } } void show_stdent_avgscore(int student_id) { float student_avgscore = 0; cout << "请输入学生姓名:" << name[student_id] << endl; student_avgscore = (score[student_id][0] + score[student_id][1] + score[student_id][2]); students_avgscore = student_avgscore / 3; cout << "平均成绩: " << student_avgscore<<"\n"; } void show_course_avgscore(string course_name) { cout << "请输入课程名称:" <
<< endl; float course_avgscore = 0; if (course_name == "a") { for(int i = 0; i < students_nr; i++) { course_avgscore = score[i][0]+course_avgscore; } course_avgscore = course_avgscore / students_nr; cout <<"课程的平均分为:"<< course_avgscore << "\n"; } if (course_name == "b") { for (int i = 0; i < students_nr; i++) { course_avgscore = score[i][1] + course_avgscore; } course_avgscore = course_avgscore / students_nr; cout << "课程的平均分为:" << course_avgscore << "\n"; } if (course_name == "c") { for (int i = 0; i < students_nr; i++) { course_avgscore = score[i][2] + course_avgscore; } course_avgscore = course_avgscore / students_nr; cout << "课程的平均分为:" << course_avgscore << "\n"; } } void order_score_by_course(string course_name) { cout << "请输入课程名称:"<
<<"\n"; if (course_name == "a") { for (int i = 0; i < students_nr; i++) { cout << "姓名: " << name[i] << " 成绩:" << score[i][0] << " "; } } else if (course_name == "b") { for (int i = 0; i < students_nr; i++) { cout << "姓名:" << name[i] << " 成绩:" << score[i][1]<<" "; } } else if (course_name == "c") { for (int i = 0; i < students_nr; i++) { cout << "姓名:" << name[i] << " 成绩:" << score[i][2] << " "; } } }private: float score[100][3]; string name[100]; int students_nr;};int main(){ studentsscore x; x.input_students_name_and_score(); x.show_students_name_and_score(); x.show_stdents_avgscore(1); x.show_course_avgscore("a"); x.order_score_by_course("b"); return 0;}

转载地址:http://vbpowy.baihongyu.com/

你可能感兴趣的文章
运维架构服务监控Open-Falcon部署
查看>>
运维架构服务监控Open-Falcon介绍
查看>>
常用的自动化运维工具
查看>>
Kubernetes Pod 故障归类与排查方法
查看>>
K8S命令详解
查看>>
mysql常用命令
查看>>
tomcat启动乱码及访问项目中文乱码终极解决方法
查看>>
redis哨兵模式的搭建生产环境中也适用(1主+1从+1哨兵)
查看>>
Linux生产环境中,无光盘,无外网搭建yum本地仓库
查看>>
linux生产服务器挂载LVM磁盘
查看>>
linux生产环境安装jdk
查看>>
Redis的搭建和配置
查看>>
问题:登录xshell时提示-bash: LC_TIME: cannot change locale (zh_CN.UTF-8): No such file or directory 解决方法
查看>>
docker创建镜像的三种方法
查看>>
Docker的三大核心概念及基本命令
查看>>
Docker是什么,如何(两步)安装Docker及基本命令
查看>>
CentOS 7.5 安装KVM虚拟机及KVM基本命令
查看>>
解决zabbix监控创建监控项时报错Invalid first parameter.方法实践
查看>>
linxu如何创建NFS共享文件系统
查看>>
基于docker+GIT+tomcat+jenkinsd搭建CI/CD部署
查看>>