请问第13题到底应该怎么做

• 写回答

6条回答默认 最新

• 这一次有糖 2023-05-28 16:38
关注
获得1.80元问题酬金

没有10.7的程序，12->>rain.c?是写的什么

``````#13
#include <stdio.h>
#define ROWS 3
#define COLS 5

void enter_numbers(double arr[][COLS], int rows);
void calculate_average(double arr[][COLS], int rows);
double calculate_total_average(double arr[][COLS], int rows);
double max_value(double arr[][COLS], int rows);

int main(void)
{
double numbers[ROWS][COLS];
enter_numbers(numbers, ROWS);
calculate_average(numbers, ROWS);
double total_average = calculate_total_average(numbers, ROWS);
double max = max_value(numbers, ROWS);

printf("The maximum value is: %.2f\n", max);
printf("The total average is: %.2f\n", total_average);

return 0;
}

void enter_numbers(double arr[][COLS], int rows)
{
for (int i = 0; i < rows; i++)
{
printf("Enter 5 numbers for row %d: ", i + 1);
for (int j = 0; j < COLS; j++)
{
scanf("%lf", &arr[i][j]);
}
}
}

void calculate_average(double arr[][COLS], int rows)
{
for (int i = 0; i < rows; i++)
{
double sum = 0.0;
for (int j = 0; j < COLS; j++)
{
sum += arr[i][j];
}
double average = sum / COLS;
printf("The average for row %d is: %.2f\n", i + 1, average);
}
}

double calculate_total_average(double arr[][COLS], int rows)
{
double total_sum = 0.0;
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < COLS; j++)
{
total_sum += arr[i][j];
}
}
double total_average = total_sum / (ROWS * COLS);
}

double max_value(double arr[][COLS], int rows)
{
double max = arr[0][0];
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < COLS; j++)
{
if (arr[i][j] > max)
{
max = arr[i][j];
}
}
}
return max;
}

14.
#include <stdio.h>

void enter_numbers(int rows, int cols, double arr[rows][cols]);
void calculate_average(int rows, int cols, double arr[rows][cols]);
double calculate_total_average(int rows, int cols, double arr[rows][cols]);
double max_value(int rows, int cols, double arr[rows][cols]);

int main(void)
{
int rows = 3;
int cols = 5;
double numbers[rows][cols];
enter_numbers(rows, cols, numbers);
calculate_average(rows, cols, numbers);
double total_average = calculate_total_average(rows, cols, numbers);
double max = max_value(rows, cols, numbers);

printf("The maximum value is: %.2f\n", max);
printf("The total average is: %.2f\n", total_average);

return 0;
}

void enter_numbers(int rows, int cols, double arr[rows][cols])
{
for (int i = 0; i < rows; i++)
{
printf("Enter 5 numbers for row %d: ", i + 1);
for (int j = 0; j < cols; j++)
{
scanf("%lf", &arr[i][j]);
}
}
}

void calculate_average(int rows, int cols, double arr[rows][cols])
{
for (int i = 0; i < rows; i++)
{
double sum = 0.0;
for (int j = 0; j < cols; j++)
{
sum += arr[i][j];
}
double average = sum / cols;
printf("The average for row %d is: %.2f\n", i + 1, average);
}
}

double calculate_total_average(int rows, int cols, double arr[rows][cols])
{
double total_sum = 0.0;
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
total_sum += arr[i][j];
}
}
double total_average = total_sum / (rows * cols);
}

double max_value(int rows, int cols, double arr[rows][cols])
{
double max = arr[0][0];
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
if (arr[i][j] > max)
{
max = arr[i][j];
}
}
}
return max;
}

``````
评论 编辑记录

• 系统已结题 6月5日
• 修改了问题 5月28日
• 创建了问题 5月28日

悬赏问题

• ¥60 关于海信电视聚好看安装应用的问题
• ¥15 vue引入sdk后的回调问题
• ¥15 求一个智能家居控制的代码
• ¥15 ad软件 pcb布线pcb规则约束编辑器where the object matpcb布线pcb规则约束编辑器where the object matchs怎么没有+15v只有no net
• ¥15 虚拟机vmnet8 nat模式可以ping通主机，主机也能ping通虚拟机，但是vmnet8一直未识别怎么解决，其次诊断结果就是默认网关不可用
• ¥20 求各位能用我能理解的话回答超级简单的一些问题
• ¥15 yolov5双目识别输出坐标代码报错
• ¥15 这个代码有什么语法错误
• ¥15 给予STM32按键中断与串口通信
• ¥15 使用QT实现can通信