结构体当参数函数,抄了书上的一个~~

#include<stdio.h>
struct Student
{
char cName[20];
float fscore[3];
}student={"苏玉群",98.5f,89.0,93.5};
void Display{struct Student stu}
{
printf("********学生成绩********\n");
printf("姓名:%s\n",stu.cName);
printf("语文:%2f\n",stu.fScore[0]);
printf("数学:%2f\n",stu.fScore[1]);
printf("英语:%2f\n",stu.fScore[2]);
printf("平均成绩:%2f\n",(stu.fScore[0]+stu.fScore[1]+stu.fScore[2])/3);

}
int main()
{
Display(student)
return 0;
}

猜你喜欢

转载自www.cnblogs.com/redxi/p/10793433.html