下面程序的功能:有一个一维数组score,内放10个学生成绩,统计不及格的学生人数。请填空。 #include <stdio.h> int main( ) { int fun( float array[10] ) ; float score[10] ; int i , count = 0 ; printf( "input 10 scores:\n" ) ; for( i = 0 ; i < 10 ; i++ ) scanf( "%f" , &score[i] ); ________; printf( "%d\n" , count ) ; return 0 ; } int fun( float array[10] ) { int i , count = 0 ; for( i = 0 ; i < 10 ; i++ ) if( array[i] <60 ) ________; return count ; }
时间: 2024-01-16 14:02:54 浏览: 24
下面程序的功能:有一个一维数组score,内放10个学生成绩,统计不及格的学生人数。请填空。
```
#include <stdio.h>
int main( ) {
int fun( float array[10] ) ;
float score[10] ;
int i , count = 0 ;
printf( "input 10 scores:\n" ) ;
for( i = 0 ; i < 10 ; i++ )
scanf( "%f" , &score[i] );
count = fun(score); // 填空1
printf( "%d\n" , count ) ;
return 0 ;
}
int fun( float array[10] ) {
int i , count = 0 ;
for( i = 0 ; i < 10 ; i++ )
if( array[i] < 60 )
count++; // 填空2
return count ;
}
```
填空1:调用fun函数统计不及格的学生人数,需要将score数组作为参数传递给fun函数,因此填写 `count = fun(score);`。
填空2:如果学生成绩小于60分,则说明该学生不及格,需要统计不及格学生人数,因此填写 `count++;`。
相关问题
下面程序的功能:有一个一维数组score,内放10个学生成绩,统计不及格的学生人数。请填空。
下面是统计不及格学生人数的程序:
```c
int score[10] = {60, 80, 30, 40, 70, 90, 55, 66, 77, 88};
int count = 0;
for(int i=0;i<10;i++){
if(score[i]<60){
count++;
}
}
printf("不及格的学生人数为:%d", count);
```
其中,count用来统计不及格学生的人数,for循环用来遍历整个数组,如果某个学生成绩小于60,就将count加1。最后输出count的值即可。
用VC++实现:有一个一维数组score,内放10个学生成绩,求平均成绩
您好,欢迎使用 ChitGPT 进行对话!
关于您的问题,可以如下实现:
double score[10] = {85.6, 78.9, 92.5, 67.8, 80.0, 72.3, 88.5, 91.2, 76.4, 83.7};
double sum = 0;
for (int i = 0; i < 10; i++) {
sum += score[i];
}
double average = sum / 10;
printf("平均成绩为:%.2f\n", average);
以上是用 C 和 VC 实现的代码,将学生的成绩存入数组中,然后求出数组中所有成绩的总和,最后计算平均值并输出即可。
希望能解决您的问题,如果您还有其他问题,请继续提出。