本帖最后由 jackz007 于 2020-12-13 16:58 编辑 #include <stdio.h>
int main(void)
{
int d[10] , * p = d , k , m , max , min , sum ;
for(m = 10 , k = 0 ; k < m ; k ++) scanf("%d" , p + k) ;
for(sum = k = 0 , max = min = * p ; k < m ; k ++) {
sum += * p ;
if(* p > max) max = * p ;
else if(* p < min) min = * p ;
p ++ ;
}
printf("The max = %d , min = %d , average = %.2f\n" , max , min , 1.0 * sum / m) ;
}
编译、运行实况D:\00.Excise\C>cl x.c
用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.28.29334 版
版权所有(C) Microsoft Corporation。保留所有权利。
x.c
Microsoft (R) Incremental Linker Version 14.28.29334.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:x.exe
x.obj
D:\00.Excise\C>x
95 93 85 97 91 88 80 77 65 94
The max = 97 , min = 65 , average = 86.50
D:\00.Excise\C>
|