题解 | #记负均正II#

记负均正II

http://www.nowcoder.com/practice/64f6f222499c4c94b338e588592b6a62

#include<iostream>
#include<iomanip>
using namespace std;
int main(int argc,char* argv[])
{
    int num=0;
    int negCount=0,posCount=0;
    long sum=0;
    while(cin>>num)
    {
        if(num<0) negCount++;
        else{
            posCount++;
            sum+=num;
        }
    }
    cout<<negCount<<endl;
    if(posCount==0) cout<<"0.0"<<endl;
    else{
        cout.setf(ios::fixed);
        cout<<setprecision(1)<<(float)sum/posCount<<endl;
        cout.unsetf(ios::fixed);
    }
    return 0;
}
全部评论

相关推荐

allin实习的大白...:我把第二个项目发出来了,如果感兴趣可以去研究研究,欢迎交流。 https://gitee.com/jtyjtyjty333/ind-dist-ai-sec-edge-cloud https://github.com/jtylab/ind-dist-ai-sec-edge-cloud
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务