问题标题: 酷町堂:4867

0
0
已解决
陆德耀
陆德耀
修练者
修练者

题目链接: 酷町堂:4867

#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
using namespace std;
int main(){
    int cnt=0,sum=0;
    int a;
    while (true){
        cin>>a;
        if(a==0){
            break;
        }
        sum+=a;
        cnt++;
        }
        cout<<sum<<endl<<cnt<<endl<<sum/cnt; 
    return 0;
}


0
已采纳
王耀森
王耀森
中级光能
中级光能

sum/cnt要保留小数

0
刘风翔
刘风翔
新手启示者
新手启示者

头文件...换成万能头嘛

保留2位小数

 

我要回答