7-135 4111 浮点数格式

#include <algorithm>
#include <cstdint>
#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;
    std::vector<std::string> data;
    u64 max = std::numeric_limits<u64>::min();
    for (i32 i = 1; i <= n; ++i)
    {
        std::string s;
        std::cin >> s;
        std::string part1{s.substr(0, s.find("."))}, part2{s.substr(s.find(".") + 1)};
        max = std::max(max, part1.length());
        data.emplace_back(std::move(s));
    }
    bool endl{false};
    for (auto &item : data)
    {
        if (endl)
        {
            std::cout << '\n';
        }
        std::string part1{item.substr(0, item.find("."))};
        for (u64 i = 1; i <= max - part1.length(); ++i)
        {
            std::cout << ' ';
        }
        std::cout << item;
        endl = true;
    }
}
posted @ 2025-10-14 19:53  TPPPP72  阅读(4)  评论(0)    收藏  举报