| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 买学问 - 大牛一对一辅导，有问必答 买学问 - 专业的付费知识问答平台

问题点数：0  回复次数：6

得分:0

得分:0

得分:0
1.《C primer plus》中文版
2.《The C programming language》中文版
3.《C专家编程》中文版

得分:0

得分:0
#include<stdio.h>
int main(void)
{

int workers=0;
double scores=0,total_score=0,max_scores=0,avg_score=0;
while (scanf("%lf",&scores) && scores >= 0)
{
if (scores > 100)
continue;
workers++;
total_score += scores;
if (max_scores < scores)
max_scores = scores;
}
avg_score = total_score / workers;
printf("total inpue %d workers\n",workers);
printf("average score is %5.2f \n",avg_score);
printf("max score is %5.2f \n",max_scores);
return 0;
}

[此贴子已经被作者于2019-1-5 14:49编辑过]

得分:0
#include<stdio.h>
int main()
{
double score;
int count=0;
double maxScore=0,avgScore=0,sumScore=0;

while (scanf("%lf",&score)&&score>=0)
{
//成绩大于100则要求重新输入
if(score>100)
{
continue;
}
if(maxScore<score)
{
maxScore=score;
}

++count;
sumScore+=score;
avgScore=sumScore/count;
}

printf("%d %5.2f %5.2f",count,avgScore,maxScore);
return 0;
}
• 7
• 1/1页
• 1

Powered by Discuz, Processed in 0.025422 second(s), 8 queries.