c语言编程,摄氏华氏温度转换 c语言编程,摄氏华氏温度转换
c\u8bed\u8a00\u7f16\u7a0b\u4e2d\u600e\u4e48\u5c06\u534e\u6c0f\u6e29\u5ea6\u8f6c\u6362\u6210\u6444\u6c0f\u6e29\u5ea6\uff1f\u4ee3\u7801\u5982\u4e0b\uff1a
#include
void main()
{
float F,C;
printf("\u8bf7\u8f93\u5165\u60a8\u9700\u8981\u8f6c\u6362\u7684\u534e\u6c0f\u6e29\u5ea6\uff1a");
scanf("%f",&F);
C = (F-32)*5/9.0;
printf("\u5176\u5bf9\u5e94\u7684\u6444\u6c0f\u6e29\u5ea6\u4e3a\uff1a%.2f \n",C);
}
\u534e\u6c0f\u5ea6
\u534e\u6c0f\u5ea6\uff08Fahrenheit\uff09\u662f\u7528\u6765\u8ba1\u91cf\u6e29\u5ea6\u7684\u5355\u4f4d\uff0c\u7b26\u53f7\u2109\u3002\u5305\u62ec\u6211\u56fd\u5728\u5185\u7684\u4e16\u754c\u4e0a\u7edd\u5927\u591a\u6570\u56fd\u5bb6\u90fd\u4f7f\u7528\u6444\u6c0f\u5ea6\u3002
\u4e16\u754c\u4e0a\u4ec5\u5b585\u4e2a\u56fd\u5bb6\u4f7f\u7528\u534e\u6c0f\u5ea6\uff0c\u5305\u62ec\u5df4\u54c8\u9a6c\u3001\u4f2f\u5229\u5179\u3001\u82f1\u5c5e\u5f00\u66fc\u7fa4\u5c9b\u3001\u5e15\u52b3\u3001\u7f8e\u5229\u575a\u5408\u4f17\u56fd\u53ca\u5176\u4ed6\u9644\u5c5e\u9886\u571f\uff08\u6ce2\u591a\u9ece\u5404\u3001\u5173\u5c9b\u3001\u7f8e\u5c5e\u7ef4\u4eac\u7fa4\u5c9b\uff09\u3002
\u6444\u6c0f\u6e29\u5ea6
\u6444\u6c0f\u6e29\u5ea6\uff08Celsius temperature\uff09
\u4e00\u79cd\u4f7f\u7528\u5e7f\u6cdb\u7684\u6e29\u5ea6\u3002\u5386\u53f2\u4e0a\u5b83\u662f\u6444\u6c0f\u6e29\u6807\u6240\u5b9a\u4e49\u7684\u6e29\u5ea6\u3002\u73b0\u5728\u6444\u6c0f\u6e29\u6807\u5df2\u5e9f\u5f03\u4e0d\u7528\uff0c\u6444\u6c0f\u6e29\u5ea6\u6709\u4e86\u65b0\u7684\u5b9a\u4e49\u3002\u4f46\u5728\u6570\u503c\u4e0a\uff0c\u5b83\u4e0e\u8fc7\u53bb\u4eba\u4eec\u4e60\u60ef\u4f7f\u7528\u7684\u6444\u6c0f\u6e29\u6807\u6e29\u5ea6\u5f88\u76f8\u8fd1\u3002
\u6444\u6c0f\u6e29\u5ea6\u7684\u89c4\u5b9a \u628a\u5728\u6807\u51c6\u5927\u6c14\u538b\u4e0b\u51b0\u6c34\u6df7\u5408\u7269\u7684\u6e29\u5ea6\u5b9a\u4e3a0\u6444\u6c0f\u5ea6\uff0c\u6cb8\u6c34\u7684\u6e29\u5ea6\u5b9a\u4e3a100\u6444\u6c0f\u5ea6\uff0c0\u6444\u6c0f\u5ea6\u548c100\u6444\u6c0f\u5ea6\u4e2d\u95f4\u5206\u4e3a100\u4e2a\u7b49\u5206\uff0c\u6bcf\u4e2a\u7b49\u5206\u4ee3\u88681\u6444\u6c0f\u5ea6\u3002
#include
float change(float x);
void main(){
float fahr;
printf("\u8bf7\u8f93\u5165\u6444\u6c0f\u6e29\u5ea6:");
scanf("%f",&fahr);
printf("\n\u5bf9\u5e94\u7684\u534e\u6c0f\u6e29\u5ea6\u4e3a\uff1a%.1f\n\n",change(fahr));
}
float change(float x){
float cent=x*9/5+32;
return cent;
}
float change(float x);
void main(){
float fahr;
printf("请输入摄氏温度:");
scanf("%f",&fahr);
printf("\n对应的华氏温度为:%.1f\n\n",change(fahr));
}
float change(float x){
float cent=x*9/5+32;
return cent;
}
绛旓細鎽勬皬娓╂爣锛埪癈锛夊拰鍗庢皬娓╂爣锛埪癋锛変箣闂寸殑鎹㈢畻鍏崇郴涓猴細F=C脳1.8+32銆侰=(F-32)梅1.8銆C璇█鏄竴闂ㄩ潰鍚戣繃绋嬬殑銆佹娊璞″寲鐨勯氱敤绋嬪簭璁捐璇█锛骞挎硾搴旂敤浜庡簳灞傚紑鍙戙侰璇█鑳戒互绠鏄撶殑鏂瑰紡缂栬瘧銆佸鐞嗕綆绾у瓨鍌ㄥ櫒銆侰璇█鏄粎浜х敓灏戦噺鐨勬満鍣ㄨ瑷浠ュ強涓嶉渶瑕佷换浣曡繍琛岀幆澧冩敮鎸佷究鑳借繍琛岀殑楂樻晥鐜囩▼搴忚璁¤瑷銆傚敖绠...
绛旓細C璇█绋嬪簭锛歩nclude <stdio.h>int main(){double f, c;printf("璇疯緭鍏鎽勬皬娓╁害鍊硷細");scanf("%lf", &c);f = 9.0 / 5 * c + 32;printf("鍗庢皬娓╁害鍊硷細%lf\n", f);printf("璇疯緭鍏ュ崕姘忔俯搴﹀硷細");scanf("%lf", &f);c = (f - 32) * 5 / 9;printf("鎽勬皬娓╁害鍊硷細%lf\n...
绛旓細include<stdio.h> void main(){ float c,f;int n;for ( n=0,f=30;n<10;n++,f+=1.0 )while ( 1 ){ c=(f-32)/1.8;printf(" 鍗庢皬%lf搴 鎽勬皬%lf搴n",f,c);} }
绛旓細绋嬪簭濡備笅锛歩nclude <stdio.h> int main(){ int f;float c;printf("璇疯緭鍏ヤ竴涓鍗庢皬娓╁害\n");scanf_s("%d", &f);c = (float)(f - 32) * 5 / 9;printf("瀹冪殑鎽勬皬娓╁害涓:%.2f", c);} 濡傚浘锛氳皟璇曢氳繃锛
绛旓細浠g爜濡備笅锛歩nclude <stdio.h> void main(){ float F,C;printf("璇疯緭鍏ユ偍闇瑕杞崲鐨鍗庢皬娓╁害锛");scanf("%f",&F);C = (F-32)*5/9.0;printf("鍏跺搴旂殑鎽勬皬娓╁害涓猴細%.2f \n",C);} 鍗庢皬搴 鍗庢皬搴︼紙Fahrenheit锛夋槸鐢ㄦ潵璁¢噺娓╁害鐨勫崟浣嶏紝绗﹀彿鈩夈傚寘鎷垜鍥藉湪鍐呯殑涓栫晫涓婄粷澶у鏁板浗瀹堕兘浣跨敤...
绛旓細鍙互鍙傝冧笅闈㈢殑浠g爜锛歩nclude <stdio.h> int main(void){ float c,f;printf("璇疯緭鍏ヤ竴涓鍗庢皬娓╁害:\n");scanf("%f",&f);c=(f-32)*5/9;printf("瀵瑰簲鐨鎽勬皬娓╁害鏄:%.2f\n",c);}
绛旓細include<stdio.h>int main(){int d; float t,t1;printf("纭畾瑕杞崲鐨勭被鍨:\n1)鍗庢皬杞憚姘廫n");printf("2)鎽勬皬杞崕姘廫n璇烽夋嫨1鎴2:");scanf("%d",&d);printf("璇疯緭鍏ユ俯搴:");scanf("%f",&t);if(d==1){t1=(t-32)*5/9; printf("鎽勬皬娓╁害涓%.2f搴n",t1);}else{t1=t*...
绛旓細include <stdio.h>int main(){ double c, f; printf ("璇疯緭鍏鍗庢皬娓╁害锛"); scanf ("%lf", &f); c=5.0/9*(f-32); printf ("%g鍗庢皬娓╁害鏄%.2f鎽勬皬娓╁害\n", f, c); return 0;}
绛旓細鎸夌収浣犵殑瑕佹眰缂栧啓鐨鍗庢皬娓╁害杞负鎽勬皬娓╁害鐨C璇█绋嬪簭濡備笅 include<stdio.h> float FtoC(float F){ return (F-32)*5/9.0;} int main(){ float F,C;printf("璇疯緭鍏ュ崕姘忓害:\n");scanf("%f",&F);//杈撳叆鍗庢皬搴 C=FtoC(F);//璋冪敤FtoC鍑芥暟瀹炵幇鍗庢皬搴﹁浆鎽勬皬搴 printf("鎽勬皬搴︿负%.2f",C...
绛旓細include<stdio.h> main(){ float x,y;int z;printf("璇烽夋嫨:\n");printf(" (1)灏嗘俯搴︿粠鎽勬皬搴杞崲涓哄崕姘忓害銆(2)灏嗘俯搴︿粠鍗庢皬搴﹁浆鎹涓烘憚姘忓害");scanf("%d",&z);if(z==1){ printf("璇疯緭鍏ヨ杞崲鐨勬俯搴:")scanf("%f",&x);y=x*1.8+32;printf(" 杞崲鍚庣殑娓╁害涓 %f 鍗庢皬搴"...