Random rand = new Random(System.currentTimeMillis()); int a = rand.nextInt(100000000); int b = rand.nextInt(100000000); int min = a; int max = b; if( b < a ){ min = b; max = a; } int m = min % 10; if(m == 0){ min = min - 9; }else{ min = min - m; } int[] plusArray = new int[]{9,1}; int sum = 0; while(min < max){ for(int plus : plusArray){ min += plus; if(min > max){ break; } int tmp = min; while(tmp > 0){ int n = tmp % 10; if(n == 0 || n == 9){ sum++; } tmp = tmp / 10; } } } System.out.println(sum);
点赞 评论

相关推荐

威猛的小饼干正在背八股:挂到根本不想整理
点赞 评论 收藏
分享
牛客网
牛客企业服务