首先,按照学生成绩信息的组成定义结构体,输入各门课程成绩和德育积分,根据已知文化积分的计算公式,求出文化积分,再根据文化积分和德育积分的比例,求出综合积分;然后,使用冒泡排序法按照学生综合积分进行从高到低的排名,并输出排名结果;最后,输出排名前2%的学生姓名为一等奖学金,排名在2%-10%之间的学生姓名为二等奖学金,排名在10%-25%之间的学生姓名为三等奖学金。
时间: 2023-09-18 21:06:36 浏览: 52
好的,让我们来编写这个程序。首先,我们需要定义一个结构体来表示学生成绩信息,包括各门课程成绩和德育积分:
```c++
#include <iostream>
#include <string>
using namespace std;
struct Student {
string name;
double chinese;
double math;
double english;
double cultural_credits;
double moral_credits;
double cultural_points;
double comprehensive_points;
};
```
然后,我们可以编写一个函数来计算学生的文化积分和综合积分:
```c++
double calculate_cultural_points(double chinese, double math, double english) {
double total = chinese + math + english;
if (total >= 270) {
return 100.0;
} else if (total >= 240) {
return 90.0;
} else if (total >= 210) {
return 80.0;
} else if (total >= 180) {
return 70.0;
} else if (total >= 150) {
return 60.0;
} else {
return 50.0;
}
}
double calculate_comprehensive_points(double cultural_points, double moral_credits) {
return cultural_points * 0.7 + moral_credits * 0.3;
}
```
接下来,我们可以编写一个函数来进行冒泡排序,按照综合积分从高到低排名:
```c++
void bubble_sort(Student students[], int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (students[j].comprehensive_points < students[j + 1].comprehensive_points) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
}
```
最后,我们可以编写一个函数来输出奖学金名单:
```c++
void print_scholarship_list(Student students[], int n) {
int first_prize_count = n * 0.02;
int second_prize_count = n * 0.08;
int third_prize_count = n * 0.15;
cout << "一等奖学金:" << endl;
for (int i = 0; i < first_prize_count; i++) {
cout << students[i].name << endl;
}
cout << "二等奖学金:" << endl;
for (int i = first_prize_count; i < first_prize_count + second_prize_count; i++) {
cout << students[i].name << endl;
}
cout << "三等奖学金:" << endl;
for (int i = first_prize_count + second_prize_count; i < first_prize_count + second_prize_count + third_prize_count; i++) {
cout << students[i].name << endl;
}
}
```
完整的代码如下所示:
```c++
#include <iostream>
#include <string>
using namespace std;
struct Student {
string name;
double chinese;
double math;
double english;
double cultural_credits;
double moral_credits;
double cultural_points;
double comprehensive_points;
};
double calculate_cultural_points(double chinese, double math, double english) {
double total = chinese + math + english;
if (total >= 270) {
return 100.0;
} else if (total >= 240) {
return 90.0;
} else if (total >= 210) {
return 80.0;
} else if (total >= 180) {
return 70.0;
} else if (total >= 150) {
return 60.0;
} else {
return 50.0;
}
}
double calculate_comprehensive_points(double cultural_points, double moral_credits) {
return cultural_points * 0.7 + moral_credits * 0.3;
}
void bubble_sort(Student students[], int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (students[j].comprehensive_points < students[j + 1].comprehensive_points) {
Student temp = students[j];
students[j] = students[j + 1];
students[j + 1] = temp;
}
}
}
}
void print_scholarship_list(Student students[], int n) {
int first_prize_count = n * 0.02;
int second_prize_count = n * 0.08;
int third_prize_count = n * 0.15;
cout << "一等奖学金:" << endl;
for (int i = 0; i < first_prize_count; i++) {
cout << students[i].name << endl;
}
cout << "二等奖学金:" << endl;
for (int i = first_prize_count; i < first_prize_count + second_prize_count; i++) {
cout << students[i].name << endl;
}
cout << "三等奖学金:" << endl;
for (int i = first_prize_count + second_prize_count; i < first_prize_count + second_prize_count + third_prize_count; i++) {
cout << students[i].name << endl;
}
}
int main() {
int n;
cout << "请输入学生人数:";
cin >> n;
Student students[n];
for (int i = 0; i < n; i++) {
cout << "请输入第" << i + 1 << "个学生的姓名、语文成绩、数学成绩、英语成绩、文化课程学分和德育课程学分:";
cin >> students[i].name >> students[i].chinese >> students[i].math >> students[i].english >> students[i].cultural_credits >> students[i].moral_credits;
students[i].cultural_points = calculate_cultural_points(students[i].chinese, students[i].math, students[i].english);
students[i].comprehensive_points = calculate_comprehensive_points(students[i].cultural_points, students[i].moral_credits);
}
bubble_sort(students, n);
print_scholarship_list(students, n);
return 0;
}
```
这个程序可以实现按照学生综合积分进行排名,并输出奖学金名单。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)