功能:输入n个数,求这n个数中偶数的个数及平均值# include < stdio.h > main ( ) ( int inm,[填空1 ];float s = 0 ; scanf ( " % d " , & n ) ; for ( [填空2 ] ; i < = n ; i++ ) f scanf ( " % d " & m ) ; if ( [填空3 ] ) f a = a +1 ; s = s + m ; printf ( " % f , od ",[填空4 ] , a );
时间: 2024-03-29 22:39:48 浏览: 101
(C语言)输入n,统计0~n中1的个数。
5星 · 资源好评率100%
# include < stdio.h >
main ( ) {
int n, m, a = 0, i = 1;
float s = 0;
scanf ( " % d " , & n ) ;
for ( ; i <= n ; i++ ) {
scanf ( " % d " , & m ) ;
if ( m % 2 == 0 ) {
a = a + 1 ;
s = s + m ;
}
}
printf ( " % f , % d " , s / a , a ) ;
}
阅读全文