000936叶素a


私信TA

用户名:yezi123

访问量:2394

签 名:

等  级
排  名 4619
经  验 1604
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校 广东工业大学
专  业

  自我简介:

解题思路:尝试使用面向对象编程,可能稍微有点复杂

注意事项:

参考代码:

#include <cstdio>

class Worker
{
        public:
                Worker()
                {
                        average_ = 0.;
                        fail_ = 0;
                        num_ = 0;
                }

                void InputAndCompute()
                {
                        int temp;
                        scanf("%d",&temp);
                        num_++;
                        average_ = (average_ * (num_ - 1) + temp)/num_;
                        if(temp<60)
                                fail_++;
                }
                float average_;
                int fail_;
                int num_;
};

int main()
{
        int i;
        Worker computer;
        for(i=0;i<=9;i++)
        {
                computer.InputAndCompute();
        }
        printf("%.1f %d",computer.average_,computer.fail_);
        getchar();getchar();
        return 0;
}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

看了一下别的题解有十行以内搞定的。我这个也就是写着玩玩o(* ̄▽ ̄*)ブ
2021-05-03 11:52:25
  • «
  • 1
  • »