你的数据保存在哪里?数组吗?怎样的数组?
很简单的,用c++更简单
#include
void main()
{
void input(float *);
void manage(float (*p)[5]);
float score[3][5];
input(*score);
manage(score);
}
void input(float *p)
{
printf("缺镇input their scores:\n");
float *p_end;
p_end=p+15;
for(;p
scanf("%f",p);
while(*p<0||*p>100)
{
printf("error!!\tinput the score again: ");
scanf("%f"弯扮兆,p);
}
}
}
void manage(float (*p)[5])
{
int i,j,n;
float sum=0,aver=0;
printf("\ntheir scores:\n");
for(i=0;i<3;i++)
{
printf("No.%d\t",i+1);
for(j=0;j<5;j++)
printf("%6.1f",*(*(p+i)+j));
printf("\n");
}
printf("\nthe average of the third course of scores is: ");
for(i=0;i<3;i++)
{
sum+=*(*(p+i)+2);
aver=sum/3;
}
printf("%6.2f\n",aver);
printf("\n");
for(i=0;i<3;i++)
{
sum=0;
n=0;
aver=0;
for(j=0;j<5;j++)
{
sum+=*(*(p+i)+j);
aver=sum/5;
if(*(*(p+i)+j)<60)
n+=1;
}
if(n>=2)
{
printf("No.%d fails,his scores are: ",i+1);
for(j=0;j<5;j++)
printf("%6.1f",*(*(p+i)+j));
printf("\nhis average score is: %6.2f\n\n",aver);
}
}
printf("\nthe student of the average score >=90.00 or all the scores>=85.0 is: ");
n=0;
for(i=0;i<3;i++)
{
sum=0;
aver=0;
for(j=0;j<5;j++)
sum+=*(*(p+i)+j);
aver=sum/5;
for(j=0;j<5;j++)
{
if(*(*(p+i)+j)<埋租85.0)
break;
}
if(aver>=90.00||j==5)
printf("No.%d ",i+1);
else n+=1;
}
if(n==3)
printf("none");
printf("\n");
}