#include <stdio.h>
#define N 3
#define M 5
void input(double sr[][M]);
double averages(double sr[]);
double all_averages(double sr[][M]);
double get_max(double sr[][M]);
void show_result(char str[],double d);
//9.2 1.5 1.6 1.5 1.7 1.7 1.8 1.9 1.5 1.6 1.7 1.7 1.2 1.3 1.4十五个小数
int main(void)
{
?? ?int i,j;
?? ?double array[3][5] = {};
?? ?input(array);
?? ?for(i=0;i<3;i++){
?? ??? ?printf("[%d]",i);
?? ??? ?show_result("averages = ",averages(array[i]));
?? ??? ?printf("\n");
?? ??? ?}
?? ?show_result("all averages = ",all_averages(array));
?? ?printf("\n");
?? ?show_result("max = ",get_max(array));
?? ?return 0;
}
//a
void input(double sr[][M])
{
?? ?int i,j;
?? ?for(i=0;i<3;i++)
?? ?{
?? ??? ?for(j=0;j<5;j++)
?? ??? ??? ?scanf("%lf",&sr[i][j]);
?? ?}
}
//b
double averages(double sr[])
{
?? ?int i;
?? ?double total= 0.0;
?? ?for(i=0;i<5;i++)
?? ??? ?total += sr[i];
?? ?return total/5;
}
//c
double all_averages(double sr[][M])
{
?? ?int i,j;
?? ?double total = 0.0;
?? ?for(i=0;i<3;i++)
?? ?{
?? ??? ?for(j=0;j<5;j++)
?? ??? ??? ?total += sr[i][j];
?? ?}
?? ?return total/15;
}
//d
double get_max(double sr[][M])
{
?? ?int i,j;
?? ?double max = sr[0][0];
?? ?for(i=0;i<N;i++)
?? ?{
?? ??? ?for(j=0;j<M;j++){
?? ??? ??? ?if(max<=sr[i][j])
?? ??? ??? ?max = sr[i][j];
?? ??? ?}
?? ?}
?? ?return max;
}
//e
void show_result(char str[],double d){
?? ?printf("%s%lf",str,d);
}