#include ‹stdio.h> int main () float minmax(float a[l, int n, float *p, float *q) ; float arr [100], max, min, average; int n, i; scanf ("'%d", &n) ; for (i = 0; i ‹ n; i++) scanf ("%f", Sarr [i]); average = minmax ( 3分); printf("average=%.2千, max=%.2千, min=%.2fIn”,average, max, min); return 0; float minmax(float all, int n, , float *p, float *q) float sum = 0, *pi = a; "p = a[e]; *q = a[e]; while ( 3
时间: 2023-06-20 08:04:17 浏览: 123
字符串函数string.h应用举例.-综合文档
抱歉,这段代码有语法错误,无法执行。其中有一些拼写错误,例如"Sarr"应该为"arr","scanf"语句中的引号应该去掉,"3分"应该为"arr"。此外,"float all"应该为"float a[]",并且在函数内部需要对最大值和最小值进行更新。以下是修改过的代码:
```
#include <stdio.h>
float minmax(float a[], int n, float *p, float *q);
int main() {
float arr[100], max, min, average;
int n, i;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%f", &arr[i]);
}
average = minmax(arr, n, &max, &min);
printf("average=%.2f, max=%.2f, min=%.2f\n", average, max, min);
return 0;
}
float minmax(float a[], int n, float *p, float *q) {
float sum = 0;
*p = a[0];
*q = a[0];
for (int i = 0; i < n; i++) {
sum += a[i];
if (a[i] > *p) {
*p = a[i];
}
if (a[i] < *q) {
*q = a[i];
}
}
return sum / n;
}
```
阅读全文