给个例子,计算stu[]的大小
#include <stdio.h>
int main(){
float sum=0.0f; int count=0; struct student{ int stu_no; char *stu_name; float chengji; };
struct student stu[]={ {87,"Star",87.5}, {88,"Jack",67.4}, {89,"Simmon",55.9}, {90,"Micheal",88.9}, {91,"Demmon",49} };
for(int i=0;i<5;i++){ sum+=stu.chengji; if(stu.chengji<60){ count++; }else if(stu.chengji>=80 && stu.chengji<=100){ printf("学号:%d,姓名:%s,成绩:%.2f\n",stu.stu_no,stu.stu_name,stu.chengji); } } printf("不及格人数:%d\n",count); printf("平均成绩:%.2f\n",sum/5);
return 0; }
|