OneCompiler

Romanian Numeral

68
#include <iostream>
#include <map>
using namespace std;

int main() 
{
    map<int,string> roman_number = {
        {1,"I"},
        {2,"II"},
        {3,"III"},
        {4,"IV"},
        {5,"V"},
        {6,"VI"},
        {7,"VII"},
        {8,"VIII"},
        {9,"IX"},
        {10,"X"}
    };

    int num;
    cin >> num;
    string roman_num = "";

    while (num > 0) {
        if (num >= 10) {
            roman_num += roman_number[10];
            num -= 10;
        }
        else {
            roman_num += roman_number[num];
            num = 0;
        }
    }

    cout << roman_num;
    return 0;
}