7-105 3102 气球来啦

#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#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();
}

void solve()
{
    i32 n;
    std::cin >> n;
    bool endl = false;
    for (i32 i = 1; i <= n; ++i)
    {
        if (endl)
        {
            std::cout << std::endl;
        }
        char opt;
        i32 a, b;
        std::cin >> opt >> a >> b;
        if (opt == '+')
        {
            std::cout << a + b;
        }
        else if (opt == '-')
        {
            std::cout << a - b;
        }
        else if (opt == '*')
        {
            std::cout << a * b;
        }
        else
        {
            if (a % b == 0)
            {
                std::cout << a / b;
            }
            else
            {
                std::cout << std::fixed << std::setprecision(2) << static_cast<double>(a) / b;
            }
        }
        endl = true;
    }
}
posted @ 2025-10-13 09:18  TPPPP72  阅读(5)  评论(0)    收藏  举报