本人刚学C不久,有一道问题想请教大侠!
#include <stdio.h>#include<stdlib.h>
struct stu
{
int num;
char *name;
char sex;
float score;}boy[5]={
{101,"Li ping",'M',45},
{102,"Zhang ping",'M',62.5},
{103,"He fang",'F',92.5},
{104,"Cheng ling",'F',87},
{105,"Wang ming",'M',58},
}; //这是定义了外部结构型数组
main()
{
struct stu *ps; //定义了结构造数组指针
void ave(struct stu *ps); //定义了一个实参
ps=boy; //将boy的首地址赋给PS结构造数组指针
ave(ps); //这个是什么意思啊?(前面已经定了void ave(struct stu *ps); ave求平均的,为什么还要加这个)
}
void ave(struct stu *ps) //定义形参
{
int c=0,i;
float ave,s=0;
for(i=0;i<5;i++,ps++)
{
s+=ps->score; //将是5个score的值相加
if(ps->score<60) c+=1; //记录小于60的个数赋给C
}
printf("s=%f\n",s);
ave=s/5; //这个是得出的平均值返回给实参吧??
printf("average=%f\ncount=%d\n",ave,c);
system("pause");
}