2025-03-06 22:45:14 +08:00

30 lines
531 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
从键盘输入5个整数输出其最大值、最小值、平均值。(注使用for循环
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int n,s,max,min,i;
double avg;
scanf("%d",&n);
s=max=min=n;
for(i=2;i<=5;i++)
{
scanf("%d",&n);
/**********Program**********/
if(n > max){
max = n;
}
if(n < min){
min = n;
}
s+=n;
/********** End **********/
}
avg=s/5.0;
printf("max=%d,min=%d,avg=%f\n",max,min,avg);
}