logo

Crowdly

Task 2 Roman numerals are represented by the following symbols: Usually a sm...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Task 2

Roman numerals are represented by the following symbols:

I1
V5
X10
L50
C100
D500
M1000

Usually a smaller value follows a larger one: VIII = 8XII = 12. However there are 6 cases where a smaller value is placed before a larger one - in that case it is subtracted:

  • IV = 4, IX = 9
  • XL = 40, XC = 90
  • CD = 400, CM = 900

Implement a function that converts a Roman numeral string to a decimal integer.

The input string is guaranteed to be a valid Roman numeral in the range [1, 3999].

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на courses.apriorit.com?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!