c语言求及格率的函数公式 c语言求不及格率( 二 )


用C语言编程 输入某班的C语言成绩,计算出其及格率#include stdio.h
void main(){
int i,n,score,num=0;
printf("班级人数:");
scanf("%d",n);
for(i=0;in;i++)
{
scanf("%d",score);
if(score=60) num++;
}
printf("及格率:%.2f%%",num*1.0*100/n);
}
运行示例c语言求及格率的函数公式:
人数10只是个例子 。c语言求及格率的函数公式你可以规定其他值c语言求及格率的函数公式 , 并输入对应c语言求及格率的函数公式的分数 。
用c语言统计4科成绩及格率从我的学生信息管理系统完整程序中摘录出题主需要的部分吧~
#include stdio.h
#include stdlib.h
#include string.h
#include time.h
#define status int
#define NAME 30 /*各类名称字数上限*/
#define STU 100 /*学生人数上限*/
#define SUB 10 /*课程数上限*/
typedef struct record {
float score; /*成绩分数*/
} record;
typedef struct student {
int id; /*id*/
int no; /*学号*/
char name[NAME]; /*姓名*/
record scores[SUB]; /*各门课成绩分数*/
} student;
char subject[SUB][NAME]; /*课程名称*/
int main (void) {
int stuNum; /*学生人数*/
int subNum; /*课程数*/
student stu[STU+1]; /*学生结构体数组 , 最后留一位buffer*/
initProgram (stu, stuNum, subNum, 0); /*初始化*/
runMeun (stu, stuNum, subNum); /*运行菜单*/
return 0;
}
/*初始化*/
/*mode==0:测试模式,灌入测试数据*/
/*mode==1:程序写定课程数、课程名称*/
status initProgram (student stu[], int *stuNum, int *subNum, int mode) {
/*测试模式*/
if (mode==0)
inputTestStuInfo (stu, stuNum, subNum);
/*程序写定课程数、课程名称*/
else if (mode==1) {
*stuNum = 0;
*subNum = 2;
memcpy (subject[0], "语文" ,4);
memcpy (subject[1], "数学" ,4);
}
return 1;
}
/*测试数据*/
status inputTestStuInfo (student stu[], int *stuNum, int *subNum) {
status testStatus;
int i;
*subNum = 4;
memcpy (subject[0], "语文" ,4);
memcpy (subject[1], "数学" ,4);
memcpy (subject[2], "英语" ,4);
memcpy (subject[3], "理综" ,4);
*stuNum = 5;
stu[0].id=1;
stu[0].no=1001;
strcpy (stu[0].name,"Zhao");
stu[0].scores[0].score=65.5;
stu[0].scores[1].score=77;
stu[0].scores[2].score=61;
stu[0].scores[3].score=52;
stu[1].id=2;
stu[1].no=1002;
strcpy (stu[1].name,"Qian");
stu[1].scores[0].score=88;
stu[1].scores[1].score=76;
stu[1].scores[2].score=46;
stu[1].scores[3].score=52;
stu[2].id=3;
stu[2].no=1003;
strcpy (stu[2].name,"Sun");
stu[2].scores[0].score=72;
stu[2].scores[1].score=69;
stu[2].scores[2].score=90;
stu[2].scores[3].score=81;
stu[3].id=4;
stu[3].no=1004;
strcpy (stu[3].name,"Li");
stu[3].scores[0].score=98.5;
stu[3].scores[1].score=80;
stu[3].scores[2].score=76;
stu[3].scores[3].score=40;
stu[4].id=5;
stu[4].no=1005;
strcpy (stu[4].name,"Zhou");
stu[4].scores[0].score=56.5;
stu[4].scores[1].score=60.5;
stu[4].scores[2].score=54.5;
stu[4].scores[3].score=52;
return 1;
}
/*学生信息判空*/
/*为空返回1;不空返回0*/
int stuInfoEmpty (student stu[], int stuNum) {
int i,stat=0;
if (stuNum == 0)
return 1;
for (i=0; istuNum; i++)
stat+=stu[i].id;
if (!stat)
return 1;
return 0;
}
/*学生为空时的处理*/
status stuInfoEmptyOp (student stu[], int stuNum) {
puts ("尚未录入学生信息!即将返回主菜单 。");

推荐阅读