#include "stdio.h"
#include "conio.h"
#include "string.h"
float top(float(*p)[5],int n,int ave95[],int allAbove85[])
{
float sum=0,ave=0;
int i,j,a=0,b=0,c=0;
for(i=0;i<n;i++)
{ sum=0;
a=0;
for(j=0;j<n+1;j++)
{
if(*(*(p+i)+j)>=85) a++;
sum=sum+*(*(p+i)+j);}
ave=sum/(n+1);
if(ave>=90) //printf("the student number ave>90 is:%d\n",i) ;
ave95[b++] = i;
else if(ave<90&&a==5)
///printf("the student number>85 is:%d\n",i) ;
allAbove85[c++]=i;
}
}
float average(float(*p)[5],int n)
{
int i,j=0;
float ave=0,sum=0;
for(i=0;i<n;i++)
sum=sum+*(*(p+i)+j);
ave=sum/n;
printf("average=%5.2f\n",ave);
}
main()
{
int ave95[4]={-1,-1,-1,-1};
int allAbove85[4]={-1,-1,-1,-1};
float a[4][5]={{70,75,89,64,51},{89,92,88,97,93},{62,51,28,75,59},{85,86,87,89,88}};
// float average(float(*p)[5],int n);
// float top(float(*p)[5],int n);
int i,m;
average(a,4);
top(a,4,ave95,allAbove85);
printf("the student number ave>90 is:") ;
for(i = 0; i < 4 && ave95[i]!= -1; i++)
printf("%d",ave95[i]);
printf("\n the student number>85 is:",i);
for(i = 0; i < 4 && allAbove85[i]!= -1; i++)
printf("%d",allAbove85[i]);
getch();
}
i'm not sure if
this is what you want!!