7-82 1021 按位输出

#include <algorithm>
#include <cmath>
#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();
}

void solve()
{
    std::string num;
    std::unordered_map<int, std::string> map{{1, "one"}, {2, "two"},   {3, "three"}, {4, "four"}, {5, "five"},
                                             {6, "six"}, {7, "seven"}, {8, "eight"}, {9, "nine"}, {10, "ten"}};
    while (std::cin >> num)
    {
        std::string key_word_1;
        std::string key_word_2;
        std::string key_word_3;
        if (num.length() > 1)
        {
            key_word_1 = "have";
            key_word_2 = "numbers";
            key_word_3 = "are";
        }
        else
        {
            key_word_1 = "has";
            key_word_2 = "number";
            key_word_3 = "is";
        }
        std::cout << num << ' ' << key_word_1 << ' ' << map[num.length()] << ' ' << key_word_2 << ',' << key_word_3
                  << ' ';
        bool need_break = false;
        for (i64 i = num.length() - 1; i >= 0; --i)
        {
            if (need_break)
            {
                std::cout << ',';
            }
            std::cout << num[i];
            need_break = true;
        }
        std::cout << std::endl;
    }
}
posted @ 2025-10-11 17:47  TPPPP72  阅读(7)  评论(0)    收藏  举报