top1编程
← 返回题目
题解

温度转换

2 条题解

  • 0
    @ 2026-7-29 1:35:57
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        double f;
        while(cin>>f){
            double c = (f-32)*5/9;  // 华氏→摄氏
            cout<<fixed<<setprecision(2)<<c<<endl;
        }
        return 0;
    }
    
    • 0
      @ 2026-7-29 1:15:56
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          int c;
          double f;
          cin>>c;//输入摄氏温度
          //9/5是小数所以华氏温度要用小数,要把9*1.0变成小数
          f=9*1.0/5*c*1.0+32;//计算华氏温度
          cout<<fixed<<setprecision(2)<<f;
          return 0;
      }
      
      • 1