㈠ c語言編程:厘米轉換為英寸
#include<stdio.h>
intmain()
{
floatm;
printf("輸入身高(厘米) ");
scanf("%f",&m);
printf("%.2f英寸 ",m/2.54);
return0;
}
㈡ 求英尺和英寸轉化成厘米C語言
#include <stdio.h>
void main()
{
float ych,yc,lm;
printf("本程序將完成英尺和英寸轉換為厘米\n");
printf("請輸入英尺數目:");
scanf("%f",&ych);
printf("請輸入英寸數目:");
scanf("%f",&yc);
lm=ych*30.48+yc*2.54;
printf("\n%.0f英尺%.0f英寸摺合為:%.2f厘米",ych,yc,lm);
}
㈢ C語言中關於英尺、英寸、厘米的換算
(foot+inch/12)*0.3048 = cm / 100
foot+inch/12 = cm / (100 * 0.3048) = cm / 30.48
因為1foot = 12inch,所以inch / 12 < 1,所以foot = cm/30.48的整數部分 inch / 12 = cm/30.48的小數部分。
六七行就是完成這個功能。
(3)英尺英寸厘米轉換用c語言擴展閱讀:
一、英尺和英寸的知識
1、1碼 = 3英寸 ,1英尺 = 12 英寸;
2、碼英文字母是 yard
3、英尺英文字母是 foot( 單數 ) feet( 復數 )
4、英寸英文單詞是 inch ( 單數 )inches( 復數 )
二、長度單位轉換
#include<stdio.h>
#define Mile_to_meter 1609 //1英里 = 1690米
#define Foot_to_centimeter 30.48 //1英里 = 1690米
#define Inch_to_centimeter 2.54 //1英里 = 1690米
int main(){
float mile, foot, inch;
scanf("%f%f%f", &mile, &foot, &inch);
printf("%fmiles = %f meters ", mile, mile * Mile_to_meter);
printf("%ffeet = %f centimeters ", foot, foot * Foot_to_centimeter );
printf("%finches = %f centimeters ", inch, inch * Inch_to_centimeter );
return 0;
}
㈣ 用c語言 編寫一個把英寸轉換成厘米的程序 我做的作業不知道對不對
我編了個程序,你參考一下。
#include<stdio.h>
main()
{
float inch,cm;
printf("please input the inch number:");
scanf("%f",&inch);
cm=2.54*inch;
printf("the centimetre is %f\n",cm);
}
㈤ C語言中輸入厘米換算成英尺和英寸:例如輸入163:輸出:5英尺4.17323英寸:
到底什麼意思啊根據你的條件厘米數/2.54就等於英寸數了阿厘米數/(2.54*12)不就等於英尺了阿這還需要貼代碼???
㈥ C語言:厘米換算英尺英寸
#include<stdio.h>
intmain()
{
intcm,foot,inch;
doublemeter;
scanf("%d",&cm);
meter=cm/100.0;
inch=12*meter/0.3048/145;
foot=inch/12;
inch=inch%12;
printf("%d%d",foot,inch);
return0;
}
這樣寫吧,編輯器把你的double當成強制轉換來看了
㈦ 用C語言編寫一個輸入身高(cm)輸出身高英寸
#include <stdio.h>
int main()
{
float height = 0;
printf("請輸入身高單位是厘米: ");
scanf("%f", &height);
printf("身高為 %f英寸 ", height/2.54);
return 0;
}
(7)英尺英寸厘米轉換用c語言擴展閱讀:
1碼=3英尺=0.9144米
1英尺=12英寸=30.48厘米
英寸(inch,in) :1英寸=2.54厘米。
scanf()是C語言中的一個輸入函數。與printf函數一樣,都被聲明在頭文件stdio.h里,因此在使用scanf函數時要加上#include <stdio.h>。
在stdio.h頭文件中內置了幾種輸入輸出函數,如下列出:
printf 與 scanf
getchar 與 putchar
gets 與 puts
格式控制:由「%」後跟格式字元組成。將輸出數據轉換為指定格式輸出,字元串原樣輸出,轉義字元對輸出形式進行控制。
參考資料來源:網路-scanf函數
㈧ C語言中厘米換算成英寸
foot = (int)(cm / 30.48); //取整數部分
inch = ( (cm / 30.48) - foot + 0.05)*10.0; //取一位小數,考慮4舍五入+0.05.
㈨ 用C語言編寫身高單位轉換:鍵盤輸入一個英制身高(幾英尺幾英寸),計算對應的公
你是問英制轉公制:
一、公式1英尺=12英寸,1英寸=2.54厘米。
二、定義兩個浮點數變數表示英尺和英寸,輸入後,套上面公式算即可。
比如:
#include<stdio.h>
int main()
{
float feet,inch,meter;
printf("輸入身高英尺 英寸:");
scanf("%f%f",&feet,&inch);
meter=(feet*12+inch)*2.54*100;
printf("轉換後%f米\n",meter);
return 0;
}
//ps:手機打代碼,自行退格調整對齊。
㈩ C語言厘米轉換英尺
#include
void
main()
{
float
ych,yc,lm;
printf("本程序將完成英尺和英寸轉換為厘米\n");
printf("請輸入英尺數目:");
scanf("%f",&ych);
printf("請輸入英寸數目:");
scanf("%f",&yc);
lm=ych*30.48+yc*2.54;
printf("\n%.0f英尺%.0f英寸摺合為:%.2f厘米",ych,yc,lm);
}
請採納答案,支持我一下。