본문 바로가기
CodingTest/Programmers

Lv.0 구 수의 나눗셈

by yoondoo 2022. 11. 21.
728x90
public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		
		//double answer = Double.parseDouble(String.format("%.0f",(double)num1/num2*1000));
		//int ans = (int) answer;
		
		//System.out.print(ans);
		
		double res = (double)num1/num2*1000;
		int resans = (int) res;
		System.out.println(resans);
	}

처음 접근을 뒤에 소수점을 잘라내려 했는데 형변환으로 간단하게 해결되는 문제였다.

 

 

반응형

'CodingTest > Programmers' 카테고리의 다른 글

Lv.0 양꼬치  (0) 2022.11.21
Lv.0 짝수의 합  (0) 2022.11.21
Lv.0 각도기  (0) 2022.11.21
Lv.0 두 수의 합  (0) 2022.11.20
Lv.0 숫자 비교하기  (0) 2022.11.20

댓글