在线编译器 C

#include <stdio.h> int find_max_array(int size, int a[]){ int max=a[0]; for(int i=1;i<size;i++){ if(a[i]>max){ max=a[i]; } } return max; } int main() { int size; scanf("%d",&size); int a[size]; for (int i=0;i<size;i++){ scanf("%d",&a[i]); } printf("%d\n",find_max_array(size, a)); return 0; }
This code defines a function `find_max_array` that finds the maximum value in an integer array, then reads an array from user input and prints its maximum. The logic is correct and the program works as intended.

- The function `find_max_array` correctly initializes `max` with the first element and iterates through the rest to find the largest value.
- The `main` function reads the array size and elements, then calls the function and prints the result. No errors are present.