int x = 165;
System.out.println(x);
int y = (int)Math.floor( Math.log((double)Math.abs(x)) / Math.log(10.0) ) + 1;
if(y >= 3) System.out.println(x - x / 100 % 10 * 100);
자리수 대로 쭉 분기 시켜도 되는데...
걍 Math api 로 =ㅅ=
x / y 에서 y 의 자리수에 따라 오른쪽을 기준으로 잘린다..
일단 100이상일 경우 (3자리의 경우) 왼쪽 100을 빼는 공식..
잃어버리기 않게 -_-
System.out.println(x);
int y = (int)Math.floor( Math.log((double)Math.abs(x)) / Math.log(10.0) ) + 1;
if(y >= 3) System.out.println(x - x / 100 % 10 * 100);
자리수 대로 쭉 분기 시켜도 되는데...
걍 Math api 로 =ㅅ=
x / y 에서 y 의 자리수에 따라 오른쪽을 기준으로 잘린다..
일단 100이상일 경우 (3자리의 경우) 왼쪽 100을 빼는 공식..
잃어버리기 않게 -_-


덧글