首页IT科技roman numeral什么意思(Roman numerals/Encode Rosetta Code)

roman numeral什么意思(Roman numerals/Encode Rosetta Code)

时间2025-09-10 02:13:50分类IT科技浏览7068
导读:C++ #include...

C++

#include <iostream> #include <string> std::string to_roman(int value) { struct romandata_t { int value; char const* numeral; }; static romandata_t const romandata[] = { 1000, "M", 900, "CM", 500, "D", 400, "CD", 100, "C", 90, "XC", 50, "L", 40, "XL", 10, "X", 9, "IX", 5, "V", 4, "IV", 1, "I", 0, NULL }; // end marker std::string result; for (romandata_t const* current = romandata; current->value > 0; ++current) { while (value >= current->value) { result += current->numeral; value -= current->value; } } return result; } int main() { for (int i = 1; i <= 4000; ++i) { std::cout << to_roman(i) << std::endl; } }

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
玩什么游戏可以赚人民币快(什么游戏可以挣人民币-“踢馆”休闲赛道,这款游戏月入1.8亿,霸榜美国免费榜38天) windows11更新卡在2%(Win11系统更新卡在100%怎么办 win11更新卡住的解决方法)