题目
代码
package fushi;
import java.util.Scanner;
public class test1 {
static boolean Judge(int n) {
int temp = n;//temp为标记数
if(temp%7==0) //7的倍数
return true;
while(temp>=1) {//含7的树
if(temp%10==7)
return true;
temp=temp/10;
}
return false;
}
public static void main(String[] args) {
while(true) {
int[] player = {0,0,0,0};//甲为player[0] 甲乙丙丁以此类推
int count=0;//一个逼近n的计数器
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();//总共报出n个数
int num=0;//从0开始 然后1开始
while(count<n) {
num++;//1开始
if(Judge(num)){//如果是7则进行判断是哪个人的
if(num%4==1) {
player[0]=player[0]+1;
}else if(num%4==2) {
player[1]=player[1]+1;
}else if(num%4==3) {
player[2]=player[2]+1;
}else if(num%4==0) {
player[3]=player[3]+1;
}
}else count++;//如果不是7则前进1位
}
for (int j = 0; j < 4; ++j) {
System.out.println(player[j]);
}
}
}
}