每日一题(3)——统计合格率

        我们来看一个案例:

        如何理解 pass【j】++ ? 

        我一直没有想通,自己重新测试了一些数据;

        下面的数组是我随便插入的数据;

class doubleArray{
    public static void main(String[] args){
       int[][] a={{71,25},{99,39},{55,67},{77,44},{44,59}};//5个学生的两科成绩
       double [] pass =new double[2];//数学与语文两个科目
        int total=a.length;
        for(int i=0;i<total;i++){
           for(int j=0;j<2;j++){
               if(a[i][j]>=60){
                   pass[j]=pass[j]+1;
                   System.out.println(pass[j]);//看看pass[j]是哪些数据
                   System.out.println("------");
               }
           }
        }
        System.out.println("----------------------------");
        System.out.println(pass[0]);//测试pass[0]有几个
        System.out.println(pass[0]/total*100+"%");
        System.out.println(pass[1]);//测试pass[1]有几个
        System.out.println(pass[1]/total*100+"%");
    }
}
1.0
------
2.0
------
1.0
------
3.0
------
----------------------------
3.0
60.0%
1.0
20.0%

进程已结束,退出代码0

        

        


 

  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值