7-1 厘米换算英尺英寸 (15 分)
如果已知英制长度的英尺foot和英寸inch的值,那么对应的米是(foot+inch/12)×0.3048。现在,如果用户输入的是厘米数,那么对应英制长度的英尺和英寸是多少呢?别忘了1英尺等于12英寸。
输入格式:
输入在一行中给出1个正整数,单位是厘米。
输出格式:
在一行中输出这个厘米数对应英制长度的英尺和英寸的整数值,中间用空格分开。
输入样例:
170
输出样例:
5 6
AC代码:
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
double n, foot;
int inch;
cin >> n;
foot = n / 30.48;
inch = (foot - floor(foot)) * 12;//取foot小数位
int Foot = (int)foot;
cout << Foot << " " << inch;
return 0;
}