关于结构体中如何计算的问题
#include <stdio.h>struct student
{
int num;
char name[21];
char sex;
int math;
int english;
int c;
int ave;
};
struct student ave(struct student a,struct student b,struct student c)
{
struct student zl;
z1.ave=stu1.math+stu1.english+stu1.c;
return z1;
}
int main(void)
{
int average;
struct student stu1;
stu1.num=4004;
stu1.sex='M';
printf("num,name,sex,math,english,c\n");
scanf("%s",stu1.name);
scanf("%d%d%d",&stu1.math,&stu1.english,&stu1.c);
average=ave(stu1.math,stu1.english,stu1.c);
printf("学号 名字 性别 数学 英语 c语言 平均分\n");
printf("%d %s %3c %3d %3d %3d %3d\n",stu1.num,stu1.name,stu1.sex,stu1.math,stu1.english,stu1.c,average);
}
各位好,我打算在这个程序中把数学、英语、c语言三门课的平均成绩求出来,但是试了好久还是出错,特来求教!