这串代码提示的错误怎么解决啊
其他问答
1
#include"stdio.h"
float fun(float tt,int n,float *max,float *min);
int main()
{
float arry[20],max,min;
int n,i;
printf("Please enter the array length:");
printf("Please enter a value for each element:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%f",&arry[i]);
}
fun(arry,n, max, min);
printf("average=%.2f,max=%.2f,min=%.2f"average,max,min);
}
fun(float *tt,int n,float *max, float *min)
{
float average=0;
for(int i=0;i<n;i++)
{
max=tt[0],min=tt[0];
if(tt[i]<tt[i+1]) max=tt[i+1];
else if(tt[i]>tt[i+1]) min=[i+1];
average+=tt[i];
}
average=average/n;
}
[Error] cannot convert 'float' to 'float*' in assignment
-
#include"stdio.h" float fun(float *tt,int n,float *max,float *min); int main() { float arry[20],max,min,average; int n,i; printf("Please enter the array length:"); printf("Please enter a value for each element:"); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%f",&arry[i]); } average=fun(arry,n, &max, &min); printf("average=%.2f,max=%.2f,min=%.2f",average,max,min); } float fun(float *tt,int n,float *max, float *min) { float average=0; for(int i=0;i<n;i++) { *max=tt[0],*min=tt[0]; if(tt[i]<tt[i+1]) *max=tt[i+1]; else if(tt[i]>tt[i+1]) *min=tt[i+1]; average+=tt[i]; } average=average/n; return average; }
-
第3行fun函数的第一个参数类型和第20行的第一个参数类型不一致 第20行的fun函数前面也没有写返回值
发表回复