1
0

c8-14.c 572 B

123456789101112131415161718192021222324252627
  1. #include <stdio.h>
  2. int main()
  3. {void average(float *p,int n);
  4. void search(float (*p)[4],int n);
  5. float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};
  6. average(*score,12);
  7. search(score,2);
  8. return 0;
  9. }
  10. void average(float *p,int n)
  11. {float *p_end;
  12. float sum=0,aver;
  13. p_end=p+n-1;
  14. for(;p<=p_end;p++)
  15. sum=sum+(*p);
  16. aver=sum/n;
  17. printf("average=%5.2f\n",aver);
  18. }
  19. void search(float (*p)[4],int n)
  20. {int i;
  21. printf("The score of No.%d are:\n",n);
  22. for(i=0;i<4;i++)
  23. printf("%5.2f ",*(*(p+n)+i));
  24. printf("\n");
  25. }