用c++实现体测评分系统
抱歉,作为语言模型AI,我没有本地环境,无法为您提供完整的实现代码。但我可以为您提供一个基本的体测评分系统的思路。
-
定义一个结构体或类,用于存储学生的基本信息和体测数据,例如姓名、性别、年龄、身高、体重、肺活量、50米跑成绩等。
-
设定评分标准,例如通过性别和年龄来确定标准,例如男生和女生的肺活量、50米跑成绩等标准不同,不同年龄段的标准也不同。
-
编写函数,根据学生的数据和评分标准,计算出该学生的体测评分,并将评分存储在结构体或类中。
-
编写主函数,用于输入学生的数据并调用函数计算评分,最后输出学生的基本信息和评分。
下面是一个简单的示例代码:
#include <iostream>
#include <string>
using namespace std;
// 定义结构体,存储学生信息和评分
struct Student {
string name; // 学生姓名
char gender; // 学生性别,'M'表示男生,'F'表示女生
int age; // 学生年龄
double height; // 学生身高,单位:米
double weight; // 学生体重,单位:千克
double lungCapacity; // 学生肺活量,单位:毫升
double runScore; // 学生50米跑成绩,单位:秒
double totalScore; // 学生总评分
};
// 定义函数,计算学生评分
void calculateScore(Student& student) {
double score = 0.0;
if (student.gender == 'M') { // 男生标准
if (student.age <= 18) { // 18岁以下
score += (student.lungCapacity - 1500) / 100.0;
score += (10 - student.runScore) / 0.5;
} else { // 18岁及以上
score += (student.lungCapacity - 2500) / 100.0;
score += (12 - student.runScore) / 0.5;
}
} else { // 女生标准
if (student.age <= 18) { // 18岁以下
score += (student.lungCapacity - 1200) / 100.0;
score += (11 - student.runScore) / 0.5;
} else { // 18岁及以上
score += (student.lungCapacity - 2000) / 100.0;
score += (13 - student.runScore) / 0.5;
}
}
student.totalScore = score;
}
int main() {
Student student;
cout << "请输入学生姓名:" << endl;
getline(cin, student.name);
cout << "请输入学生性别(M表示男生,F表示女生):" << endl;
cin >> student.gender;
cout << "请输入学生年龄:" << endl;
cin >> student.age;
cout << "请输入学生身高(单位:米):" << endl;
cin >> student.height;
cout << "请输入学生体重(单位:千克):" << endl;
cin >> student.weight;
cout << "请输入学生肺活量(单位:毫升):" << endl;
cin >> student.lungCapacity;
cout << "请输入学生50米跑成绩(单位:秒):" << endl;
cin >> student.runScore;
calculateScore(student);
cout << "学生姓名:" << student.name << endl;
cout << "学生性别:" << student.gender << endl;
cout << "学生年龄:" << student.age << endl;
cout << "学生身高:" << student.height << "米" << endl;
cout << "学生体重:" << student.weight << "千克" << endl;
cout << "学生肺活量:" << student.lungCapacity << "毫升" << endl;
cout << "学生50米跑成绩:" << student.runScore << "秒" << endl;
cout << "学生总评分:" << student.totalScore << endl;
return 0;
}
这是一个简单的体测评分系统,实际应用中还需要结合具体的评分标准和要求进行更加详细的设计和实现
原文地址: https://www.cveoy.top/t/topic/g90p 著作权归作者所有。请勿转载和采集!