按c语言 百分制输入学生的考试分数,统计及格率。
时间: 2023-05-19 10:07:08 浏览: 172
可以使用以下代码实现:
#include <stdio.h>
int main() {
int score, pass_count = 0, total_count = 0;
float pass_rate;
printf("请输入学生的考试分数(输入-1结束):\n");
while (1) {
scanf("%d", &score);
if (score == -1) {
break;
}
total_count++;
if (score >= 60) {
pass_count++;
}
}
pass_rate = (float)pass_count / total_count * 100;
printf("及格率为:%.2f%%\n", pass_rate);
return 0;
}
阅读全文
相关推荐
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![text/x-c](https://img-home.csdnimg.cn/images/20250102104920.png)
![text/x-c](https://img-home.csdnimg.cn/images/20250102104920.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)