[C.C++] C语言F/C温度转换

860 0
Honkers 2025-7-30 05:56:50 来自手机 | 显示全部楼层 |阅读模式
  1. #include<stdio.h>
  2. int main ()
  3. {
  4. char a;
  5. float temperature;
  6. printf("请输入温度类型(F/C)及温度:\n");
  7. scanf("%c,%f",&a,&temperature);
  8. if(a=='C')
  9. {
  10. temperature=(temperature*9/5)+32;
  11. printf("The Fahrenheit is%.2f\n",temperature);
  12. }
  13. if(a=='F')
  14. {
  15. temperature=(temperature-32)*5/9;
  16. printf("The Centigrade is%.2f\n",temperature);
  17. }
  18. return 0;
  19. }
复制代码

 

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行