这里面的第13题的答案怎么写有会的可以帮我一下忙吗这里非常感谢了3个小题都要用指针写
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); return total_average; } 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); return total_average; } 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; }
解决 1无用
悬赏问题
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 保护模式-系统加载-段寄存器