#include <stdio.h>
struct team{
char name[32];// 姓名
long tel;// 电话
char sex;// 性别
float score;// 成绩
};
struct team n1={"wang",123456,'m',13.2};
struct team n2={"li",23456,'w',70.8};
struct team n3={"qian",367,'m',90.4};
void main() {
float avg;
avg=(n1.score+n2.score+n3.score)/3.0;
printf("%f",avg); //58.133335
}
C语言 计算平均分
于 2021-03-28 01:57:43 首次发布
该博客展示了一个C语言程序,定义了一个结构体类型`struct team`,包含姓名、电话、性别和成绩字段。然后创建了三个结构体变量,分别存储了三个人的信息,并计算了他们的平均分数,输出结果为58.133335。

1552

被折叠的 条评论
为什么被折叠?



