功能:输入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 11:39:50 浏览: 34
C语言函数库
# 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 ) ;
}
阅读全文