Roman numerals · الأرقام الرومانية
Roman numerals
Convert a Roman numeral to an int. The symbols are I=1, V=5, X=10, L=50, C=100, D=500, M=1000. Usually you add, but when a smaller symbol sits before a larger one you subtract it: IV is 4, IX is 9, MCMXCIV is 1994. Scanning from right to left makes the subtract rule easy — subtract any symbol smaller than the one to its right.
الأرقام الرومانية
حوّل رقماً رومانياً إلى int. الرموز هي I=1، V=5، X=10، L=50، C=100، D=500، M=1000. عادة ما تجمع، ولكن عندما يكون رمز أصغر قبل رمز أكبر تطرحه: IV يساوي 4، IX يساوي 9، MCMXCIV يساوي 1994. المسح من اليمين إلى اليسر يجعل قاعدة الطرح سهلة — اطرح أي رمز أصغر من الذي على يمينه.
Complete romanToInt(String s) converting a Roman numeral to an int. A smaller symbol before a larger one is subtracted, so IV is 4 and MCMXCIV is 1994. Assume valid input. · أكمل romanToInt(String s) لتحويل رقم روماني إلى int. الرمز الأصغر قبل الأكبر يُطرح، لذا IV هي 4 وMCMXCIV هي 1994. افترض مدخلاً صالحاً.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.