1:定义合适类型变量用来存储科目,分数等
2:判断科目如果nWork <= 0 || nWork > 4则重新输入
3:循环依次输入各科目分数
4:判断分数是否超出范围0 > nScore[i] || 100 < nScore[i]
5:超出则重新输入
6:累加正确分数
7:计算平均分
8:输出平均分
demo
int nWork = 0;
float nScore[4] = 0.0;
float fAvg = 0.0;
float fAll = 0.0;
do
{
printf("Please input the work NO..\n");
scanf("%d",&nWork);
}
while(nWork <= 0 || nWork > 4)
for(int i = 0 ;i<nWork-1;i++)
{
do
{
scanf("%f",nScore[i]);
}
while(0 > nScore[i] || 100 < nScore[i])
fAll += nScore[i];
}
fAvg = fAll/nWork
printf("The avg score is :%f",fAvg);
追问我们老师教的是没有那种括号的,不是这种类型的。。。用的是if..and...then语法,然后还有就是if一段完了以后第二行还要加一个endif,大哥你会那种的么
追答是哪一种语言 VB?还是其他脚本语言?