[Java] Baekjun No. 1008 - A/B
We summarized how to solve the A/B problem in Java using integer division and real number conversion.
한국어 원문은 여기에서 볼 수 있습니다.
[Java] Baekjun No. 1008 - A/B
Solution
1
2
3
4
5
6
7
8
9
10
11
12
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int num1 = input.nextInt();
int num2 = input.nextInt();
System.out.print((double)num1 / num2);
}
}
/ division operation in Java
정수 / 정수: The result isint, i.e. returns only the quotient.- To return the entire division result, including real numbers, type conversion must be done using either
doubleorfloat.