软件工程报告2大奖赛计分

作者 郭聪

#include <stdio.h> float cabscore(float score)//返回值为小数形式,刚开始是定义为整数,会导致评委打分时不能进入下一个评委; {     if(score>=0&&score<=10)        score=score;     else        {

      printf("请重新输入分数");         scanf("%f",&score);         cabscore(score); }//避免再次给出一个不符合规则的数字         return score; } void calscore(int n) {    int i=1;     //i代表评委的编号      float   max=-1;      float   min=11;      float ave=0,score,sum=0;         printf("请输入选手的成绩(0-10)\n");     do         {             printf("第 %d 位评委给分:", i);             scanf("%f", &score);             score=cabscore(score);//             sum+=score;             if(max<score)                 max=score;             if(min>score)                 min=score;             i++;         }while(i<=n);         //下面开始计算         ave = (sum-max-min)/(n-2);         printf("减去一个最高分: %.3f\n", max);         printf(", 减去一个最低分: %.3f\n", min);         printf("当前选手的最后得分是:%.3f\n", ave); }

int main( ) {     int i,n;     double ave, score, sum, max, min;     char choice;      printf("请输入评委人数");      scanf("%d",&n);     do     //计算选手的成绩,至少1次     {

        calscore(n);         printf("******************* SUCCESS ***********************\n");         printf("按 N 退出,其他键继续....");         fflush(stdin);   //将输入缓冲清空,否则getchar()会读入之前录入中的回车等符号         choice=getchar();     }while(choice!='N' && choice!='n'); //不管输入大小写,全算数     return 0; }

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值