记负均正

记负均正

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

import java.util.Scanner;


public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int count1 = 0;
            int count2 = 0;
            int sum = 0;
            int in = 0;

            for(int i = 0; i < n; i++){
                in  = sc.nextInt();
                if(in > 0){
                    count1++;
                    sum += in;
                }else if(in < 0){
                    count2++;
                }
            }
            System.out.printf("%d %.1f\n",count2, (sum * 1.0 / count1));
        }
    }    
}
全部评论

相关推荐

11-15 19:28
已编辑
蚌埠坦克学院 硬件开发
点赞 评论 收藏
分享
评论
2
2
分享
牛客网
牛客企业服务