某班的数学考试成绩如下:+90、78、98、67、53、97、78、100、76、88。编程计算并输出该班的总人数、最高分、最低分和平均分
时间: 2023-11-24 09:52:10 浏览: 62
该班的数学考试成绩如下:+90、78、98、67、53、97、78、100、76、88。编程计算并输出该班的总人数、最高分、最低分和平均分的Python代码如下:
```python
scores = [90,78, 98, 67, 53, 97, 78, 100, 76, 88]
total = len(scores) # 总人数
max_score = max(scores) # 最高分
min_score = min(scores) # 最低分
avg_score = sum(scores) / total # 平均分
print("总人数:", total)
print("最高分:", max_score)
print("最低分:", min_score)
print("平均分:", avg_score)
```
输出结果为:
```
总人数: 10
最高分: 100
最低分: 53
平均分: 82.5
```
相关问题
C语言某班数学考试成绩如下:90,78+,98,67,53,97,78,100,76,88编程输出该班的总人数,最高分,最低分和平均分
以下是C语言代码,可以输出该班的总人数,最高分,最低分和平均分:
```c
#include <stdio.h>
int main() {
int scores[] = {90, 78, 98, 67, 53, 97, 78, 100, 76, 88};
int len = sizeof(scores) / sizeof(scores[0]);
int sum = 0, max = scores[0], min = scores[0];
float avg;
for (int i = 0; i < len; i++) {
sum += scores[i];
if (scores[i] > max) {
max = scores[i];
}
if (scores[i] < min) {
min = scores[i];
}
}
avg = (float)sum / len;
printf("总人数:%d\n", len);
printf("最高分:%d\n", max);
printf("最低分:%d\n", min);
printf("平均分:%.2f\n", avg);
return 0;
}
```
输出结果为:
```
总人数:10
最高分:100
最低分:53
平均分:82.70
```
用C语言实现以下程序:某班的数学考试成绩如下90、78、98、67、53、97、78、100、76、88,输出该班总人数、最高分、最低分和平均分
以下是用C语言实现该程序的代码:
```c
#include <stdio.h>
int main() {
int scores[] = {90,78, 98, 67, 53, 97, 78, 100, 76, 88};
int sum = 0, max = scores[0], min = scores[0];
int count = sizeof(scores) / sizeof(scores[0]);
float average;
for (int i = 0; i < count; i++) {
sum += scores[i];
if (scores[i] > max) {
max = scores[i];
}
if (scores[i] < min) {
min = scores[i];
}
}
average = (float)sum / count;
printf("该班总人数为:%d\n", count);
printf("该班最高分为:%d\n", max);
printf("该班最低分为:%d\n", min);
printf("该班平均分为:%.2f\n", average);
return 0;
}
```
输出结果为:
```
该班总人数为:10
该班最高分为:100
该班最低分为:53
该班平均分为:83.70
```
相关推荐
![java](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![xls](https://img-home.csdnimg.cn/images/20210720083658.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)
![c](https://img-home.csdnimg.cn/images/20210720083646.png)
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)