#include<stdio.h>
void average(float *p,int n);
void search(float (*p)[4],int n);
void main()
{
float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
average(* score,12);
search(score,2);
}
void average(float *p,int n)
{
float * p_end=p+n-1;
float sum=0,aver;
for(;p<=p_end;p++)
sum=sum+(*p);
aver=sum/n;
printf("average=%5.2f\n",aver);
}
void search(float (*p)[4],int n)
{
int i;
printf("the score of No.%d are:\n",n);
for(i=0;i<4;i++)
printf("%f ",*(*(p+n)+i));
puts("\n");
}
学习C/C++语言:指针与多维数组
最新推荐文章于 2023-11-20 23:48:58 发布