- #include<conio.h>
- #include<stdio.h>
- #define N 20
- int fun(float *s,int n,float *aver)
- {
- float ave,t=0.0;
- int count = 0,k,i;
-
- for(k = 0;k < n;k++)
- t + =s[k];
- ave = t / n;
- for(i=0;i<n;i++)
- if(s[i]<ave)
- count++;
- *aver = ave
- return count;
- }
- int main()
- {
- float s[30],aver;
- int m,i;
- printf("plase enter m:");
- scanf("%d",&m);
- printf("please enter %d mark:\n",m)
- for(i=0;i<m;i++)
- scanf("%f",s+i) ;
- printf("the number of students :\n",fun(s,m,&aver));
- printf("ave=%f\n",aver);
- return 0;
- }
复制代码
#include<conio.h>
#include<stdio.h>
#define N 20
int fun(float *s,int n,float *aver)
{
float ave,t=0.0;
int count = 0,k,i;
for(k = 0;k < n;k++)
t + =s[k];
ave = t / n;
for(i=0;i<n;i++)
if(s<ave)
count++;
*aver = ave
return count;
}
int main()
{
float s[30],aver;
int m,i;
printf("plase enter m:");
scanf("%d",&m);
printf("please enter %d mark:\n",m)
for(i=0;i<m;i++)
scanf("%f",s+i)
printf("the number of students :\n",fun(s,m,&aver));
printf("ave=%f\n",aver);
return 0;
}
#include<conio.h>
#include<stdio.h>
#define N 20
int fun(float *s,int n,float *aver)
{
float ave,t=0.0;
int count = 0,k,i;
for(k = 0;k < n;k++)
t + =s[k];
ave = t / n;
for(i=0;i<n;i++)
if(s<ave)
count++;
*aver = ave
return count;
}
int main()
{
float s[30],aver;
int m,i;
printf("plase enter m:");
scanf("%d",&m);
printf("please enter %d mark:\n",m)
for(i=0;i<m;i++)
scanf("%f",s+i)
printf("the number of students :\n",fun(s,m,&aver));
printf("ave=%f\n",aver);
return 0;
}
为什么把*aver = ave 改为aver = &ave 不对???感觉是对的?哪里的问题!!!! |