示例代码:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int n = 0 ;
int i = 0 , max = 0 , min = 0 , sum = 0;
int* num;
scanf("%d",&n);
num = (int *)malloc(sizeof(int)*n);
for (i = 0 ; i < n ; i ++)
{
scanf("%d",&num[i]);
}
max = min = num[0];
for (i = 0 ; i < n ; i ++)
{
if (max < num[i])
{
max = num[i];
}
if (min > num[i])
{
min = num[i];
}
sum += num[i];
}
printf("%d\n",max);
printf("%d\n",min);
printf("%d\n",sum);
free(num);
num = NULL;
return 0;
}