JAVA
[자바] 정수 n에서 7의 개수 구하기
div_yeri
2023. 1. 3. 11:57
728x90
public class Test {
public static void main(String[] args) {
int n = 2797879;
int count = 0;
while(n != 0) {
if(n % 10 == 7) count++; n /= 10;
}
System.out.println("7의 갯수 : " + count);
}
}