题解 | #记负均正#

记负均正

http://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws InterruptedException {
        Scanner sc=new Scanner(System.in);
        int fs=0;
        int zs=0;
        float avg=0;
        Integer n=sc.nextInt();
        int[] nums=new int[n];
        for (int i = 0; i < n; i++) {
            int x=sc.nextInt();
            if(x>0){
                zs++;
                avg+=x;
            }
            if(x<0){
                fs++;
            }
        }
        if(zs==0){
            System.out.format("%d %.1f",fs,0.0); 
        }else{
             System.out.format("%d %.1f",fs,avg/zs); 
        }
        


    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
熊大不大:微信也是华为旗下吧,我看我朋友也是华为工牌写wx
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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