3416. 摄氏华氏转换

Fifnmar

include

#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    char x = 'f';
    if (a.back() == 'f')
        x = 'c';
    a.pop_back();
    double num = stoi(a);
    cout << fixed << setprecision(2) << (x == 'f' ? (num * 9 / 5) + 32 : (num - 32) * 5 / 9) << x;
}
你当前正在回复 博客/题目
存在问题!