def int_to_roman(num):
    # قائمة الرموز الرومانية مع قيمها المقابلة
    roman_numerals = [
        (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")
    ]
    
    roman_numeral = ''
    
    # التحويل إلى الرقم الروماني
    for value, symbol in roman_numerals:
        while num >= value:
            roman_numeral += symbol
            num -= value
    
    return roman_numeral

# دع المستخدم يدخل الأرقام وتحويلها إلى أرقام رومانية
while True:
    try:
        num = int(input("الرجاء إدخال عدد صحيح (Ctrl+C للخروج): "))
        if num <= 0 or num > 3999:
            print("يرجى إدخال عدد صحيح بين 1 و 3999.")
            continue
        
        roman = int_to_roman(num)
        print(f"العدد الروماني المقابل لـ {num} هو: {roman}\n")
    
    except ValueError:
        print("خطأ! الرجاء إدخال عدد صحيح صحيح.")

