#include <stdio.h>
#include <stdlib.h>
#define MAXN 10
typedef float ElementType;
ElementType Max(ElementType S[], int N);
int main()
{
ElementType S[MAXN];
int N, i;
scanf_s("%d", &N);
/*if (N > MAXN)
{
printf("Error!");
exit(0);
}*/
for (i = 0; i < N; i++)
{
scanf_s("%f", &S[i]);
}
printf("%.2f\n", Max(S, N));
return 0;
}
/* 你的代码将被嵌在这里 */
ElementType Max(ElementType S[], int N)
{
if (N > MAXN)//数组越界判断
{
printf("Error!");
exit(0);
}
float max = S[0];//max初值不可以设置为0,需要考虑数组全部为负数的情况
for (int i = 0; i < N; i++)
{
if (max < S[i])
{
max = S[i];
}
}
return max;
}
03-22
8214
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-24
08-17
1079
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)