Given foot and inch, the meter is (foot+inch/12)×0.3048.
What sould be the feet and inches for an input centimetre?
PS:One foot is 12 inches.
Input Format:
One integer in terms of cm.
Output Format:
One integer for the feet and another integer for the inches.
Sample Input:
170
Sample Output:
5 6
题解: 这个可以看成一个实数,可以看成两部分组成,整数部分由英尺组成,小数部分由英寸组成,我们要的是整数,所以n/30.48直接取整,小数部分带入公式即可
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int foot = (int)(n / 30.48); int inch = (int)((n / 30.48 - foot) * 12); System.out.println(foot + " " + inch); } }