알고리즘/코딩도장
구글 입사 문제 중에서
개발계발게발
2021. 5. 28. 15:53
반응형
코딩도장 - 구글 입사 문제 중에서
public class Main {
public static void main(String[] args) {
int[] N = new int[10000];
int count = 0;
for (int i = 0; i < N.length; i++) {
N[i] = i; // 값 대입용
if (N[i] % 10 == 8) {
//System.out.println(i + " 1의 자리"); // 1의 자리 카운트
count++;
}
N[i] = N[i] / 10;
if (N[i] % 10 == 8) {
//System.out.println(i + " 10의 자리"); // 10의 자리 카운트
count++;
}
N[i] = N[i] / 10;
if (N[i] % 10 == 8) {
//System.out.println(i + " 100의 자리"); // 100의 자리 카운트
count++;
}
N[i] = N[i] / 10;
if (N[i] % 10 == 8) {
//System.out.println(i + " 1000의자리"); /// 1000의 자리 카운트
count++;
}
}
System.out.println(count);
}
}
반응형