编写程序,将输入数据的单位由mile转换到km.已知1mile等于5280foot,1foot=12in,1in=254cm,1km=100000c

问题描述:

编写程序,将输入数据的单位由mile转换到km.已知1mile等于5280foot,1foot=12in,1in=254cm,1km=100000c

用什么语言写呢.
计算公式很简单啦:公里数 = 英里数*5280*12*2.54/100000 就可以了.
如果使用C语言:
constant int mile2foot = 5280;
constant int foot2inch = 12;
constant float inch2cent = 2.54; (should be 2.54,not 254)
constant int km2cent = 100000;
float mile,kilometer;
kilometer = mile * mile2foot * foot2inch * inch2cent / km2cent;