7-77 1016 摄氏温度转换为华氏温度

#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using pii = std::pair<i32, i32>;
using pll = std::pair<i64, i64>;
using vi = std::vector<i32>;
using vll = std::vector<i64>;
using vpii = std::vector<pii>;
using vpll = std::vector<pll>;

void solve();

int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

double to_c(double f)
{
    return 5 * (f - 32) / 9;
}

double to_f(double c)
{
    return 9 * c / 5 + 32;
}

void solve()
{
    double c;
    while (std::cin >> c)
    {
        std::cout << "celsius=" << std::fixed << std::setprecision(1) << c << ',';
        std::cout << "fahr=" << std::fixed << std::setprecision(1) << to_f(c) << std::endl;
    }
}
posted @ 2025-10-11 16:57  TPPPP72  阅读(5)  评论(0)    收藏  举报