用C++ 写程序,Write a function that reads an double array and its size, then return the maximum value. The main program has been given to you. The result should be 5.9
时间: 2023-03-15 07:41:35 浏览: 104
一个C++语言编写的程序
答:以下是实现此功能的C程序:#include <stdio.h>double findMax(double array[], int size) {
int i;
double max = array[0]; for (i = 1; i < size; i++) {
if (array[i] > max) {
max = array[i];
}
} return max;
}int main() {
int size = 5;
double array[] = {1.1, 3.2, 4.2, 5.9, 0.9}; printf("The max value is: %f \n", findMax(array, size)); return 0;
}
阅读全文