题目描述
输入
输出
样例输入
样例输出
源代码
#include <stdio.h>
#include <stdlib.h>
void input ( long number[ ] , int score[ 30 ] [ 6 ] , int N) ;
void averstudent ( int score[ 30 ] [ 6 ] , float averst[ ] , int sumst[ ] , int n) ;
void avergkcj ( int score[ 30 ] [ 6 ] , float avergk[ ] , int sumgk[ ] , int n) ;
void output ( long number[ ] , float averst[ ] , float avergk[ ] , int score[ 30 ] [ 6 ] , int n) ;
void input ( long number[ ] , int score[ 30 ] [ 6 ] , int n)
{
int i, j;
for ( i = 0 ; i < n; i++ )
{
scanf ( "%ld" , & number[ i] ) ;
for ( j = 0 ; j < 5 ; j++ )
{
scanf ( "%d" , & score[ i] [ j] ) ;
}
}
}
void averstudent ( int score[ 30 ] [ 6 ] , float averst[ ] , int sumst[ ] , int n)
{
int i, j;
for ( i = 0 ; i < n; i++ )
{
sumst[ i] = 0 ;
for ( j = 0 ; j < 5 ; j++ )
{
sumst[ i] + = score[ i] [ j] ;
}
averst[ i] = ( float ) sumst[ i] / 5.00 ;
}
}
void avergkcj ( int score[ 30 ] [ 6 ] , float avergk[ ] , int sumgk[ ] , int n)
{
int i, j;
for ( i = 0 ; i < 5 ; i++ )
{
sumgk[ i] = 0 ;
for ( j = 0 ; j < n; j++ )
{
sumgk[ i] + = score[ j] [ i] ;
}
avergk[ i] = ( float ) sumgk[ i] / ( float ) n;
}
}
void output ( long number[ ] , float averst[ ] , float avergk[ ] , int score[ 30 ] [ 6 ] , int n)
{
int i, j;
for ( i = 0 ; i < n; i++ )
{
printf ( "%ld " , number[ i] ) ;
for ( j = 0 ; j < 5 ; j++ )
{
printf ( "%d " , score[ i] [ j] ) ;
}
printf ( "%.1f" , averst[ i] ) ;
printf ( "\n" ) ;
}
for ( i = 0 ; i < 5 ; i++ )
{
printf ( "%.1f " , avergk[ i] ) ;
}
}
int main ( )
{
int N;
int score[ 30 ] [ 6 ] , sumst[ 30 ] , sumgk[ 30 ] ;
long number[ 50 ] ;
float averst[ 30 ] , avergk[ 30 ] ;
scanf ( "%d" , & N) ;
input ( number, score, N) ;
averstudent ( score, averst, sumst, N) ;
avergkcj ( score, avergk, sumgk, N) ;
output ( number, averst, avergk, score, N) ;
return 0 ;
}
关于这题