#include<stdio.h>
#include<string.h>
#include<stdlib.h>
float maxmin(int *p,int n)
{
int i;
double index;
for (i=0;i<n;i++){
index= *p;
if(*(p+i)>= index )
index=*(p+i);
}
printf("max = %.2f\n",index);
for (i=0;i<n;i++){
index= *p;
if(*(p+i)<= index )
index=*(p+i);
}
printf("min = %.2f\n",index);
}
int main()
{
int n,i,*p=NULL;
scanf("%d",&n);
if((p=(int*)malloc(n*sizeof(int)))==NULL){
exit(1);
}
for(i=0;i<n;i++){
scanf("%d",p+i);
}
double sum=0;
for(i=0;i<n;i++){
sum= sum + *(p+i);
}
printf("average = %.2f\n",sum/(1.0*n));
maxmin(p,n);
free(p);
return 0;
}
李佳欣111
最新推荐文章于 2024-08-15 21:53:17 发布