指针求学生成绩,求大神指点。。。
#include<stdio.h>int main()
{
void average(float *p,int n);
void search(float (*p)[4],int n);
int score[3][4],i,j;
float aver;
printf("input students' scores:\n");
for(i=0;i<3;i++){
for(j=0;j<4;j++)
scanf("%f",score[i][j]);
}
average(*score,12);
printf("average=%f",aver);
search(score,2);
return 0;
}
void average(float *p,int n)
{
float* p_end;
float sum=0,aver;
p_end=p+n-1;
for(;p<=p_end;p++)
sum=sum+(*p);
aver=sum/n;
}
void search(float (*p)[4],int n)
{
int i;
printf("the student NO.%d are:\n");
for(i=0;i<4;i++)
printf("%f",*(*(p+n)+i));
printf("\n");
}