Leetcode 13. Roman to Integer (C語言)
- 題目
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.
- 範例
思路:羅馬數字正常由大到小排列(M>D>C>L>X>V>I),一但有小到大的情況發生(e.g. IV,IX),這時候就把後者減前者(IV=5-1=4)。