Numero romano allo strumento di conversione online digitale arabo
suNumero romano allo strumento di conversione online digitale arabo:
Questo strumento per la conversione dei numeri arabi in linea dei numeri romani ti aiuta a convertire un numero romano in un numero arabo. Inserisci il numero romano e il numero arabo verrà visualizzato nella casella dei risultati.
Numeri romani:
I numeri romani usano le lettere latine per rappresentare i numeri ("I" :"1", "V" :"5", "X" :"10", "L" :"50", "C" :"100", "D" :"500", "M" :"1000") . Il sistema dei numeri romani viene spesso utilizzato per lo smistamento di carte e libri.
Come convertire i numeri romani in numeri arabi?
Passaggio 1: ricorda i valori rappresentati dall'alfabeto latino in ordine
('I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000).Passaggio 2: da sinistra a destra, se l'alfabeto latino appare prima dell'alfabeto latino che è più grande di quello, sottrarre il valore rappresentato dall'alfabeto latino.
Esempio 2.1: IV = V - I = 5 - 1 = 4
Esempio 2.2: XL = X - L = 50 - 10 = 40
Passaggio 3: in altri casi, aumentare il valore rappresentato da questa lettera latina.
Esempio 3.1: XXXV = X + X + X + V = 10 + 10 + 10 + 5 = 35
Esempio 3.2: CXXIII = C + X + X + I + I + I = 100 + 10 + 10 + 1 + 1 + 1 = 123
Esempio 1: Convertire il numero romano "CXLVI" in cifre arabe:
Esempio 2: conversione del numero romano "CDXCIV" in numeri arabi:
Numero romano alla tabella di conversione dei numeri arabi:
| Numeri romani | Numeri arabi | Numeri romani | Numeri arabi |
|---|---|---|---|
| I | 1 | XXI | 21 |
| II | 2 | XXII | 22 |
| III | 3 | XXIII | 23 |
| IV | 4 | XXIV | 24 |
| V | 5 | XXV | 25 |
| VI | 6 | XXVI | 26 |
| VII | 7 | XXVII | 27 |
| VIII | 8 | XXVIII | 28 |
| IX | 9 | XXIX | 29 |
| X | 10 | XXX | 30 |
| XI | 11 | XXXI | 31 |
| XII | 12 | XXXII | 32 |
| XIII | 13 | XXXIII | 33 |
| XIV | 14 | XXXIV | 34 |
| XV | 15 | XXXV | 35 |
| XVI | 16 | XXXVI | 36 |
| XVII | 17 | XXXVII | 37 |
| XVIII | 18 | XXXVIII | 38 |
| XIX | 19 | XXXIX | 39 |
| XX | 20 | XL | 40 |
collegamento:
Wikipedia (sistema digitale romano): https://en.wikipedia.org/wiki/Roman_numerals
Conversione di numeri romani in numeri arabi in Python:
def transform_roman_numeral_to_number(roman_numeral):
roman_char_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
res = 0
for i in range(0, len(roman_numeral)):
if i == 0 or roman_char_dict[roman_numeral[i]] <= roman_char_dict[roman_numeral[i - 1]]:
res += roman_char_dict[roman_numeral[i]]
else:
res += roman_char_dict[roman_numeral[i]] - 2 * roman_char_dict[roman_numeral[i - 1]]
return res
roman_numeral_input = 'MMXVIII'
number_output = transform_roman_numeral_to_number(roman_numeral_input)
print('Roman numeral {0} equal to:{1}'.format(roman_numeral_input, number_output))
-------------------
Roman numeral MMXVIII equal to:2018
Numero romano alla conversione del numero arabo in Java:
import java.util.Map;
import java.util.HashMap;
public class NumberConvertManager {
public static int transform_roman_numeral_to_number(String roman_numeral) {
Map<Character, Integer> roman_char_dict = new HashMap<Character, Integer>();
roman_char_dict.put('I', 1);
roman_char_dict.put('V', 5);
roman_char_dict.put('X', 10);
roman_char_dict.put('L', 50);
roman_char_dict.put('C', 100);
roman_char_dict.put('D', 500);
roman_char_dict.put('M', 1000);
int res = 0;
for (int i = 0; i < roman_numeral.length(); i += 1) {
if (i == 0 || roman_char_dict.get(roman_numeral.charAt(i)) <= roman_char_dict.get(roman_numeral.charAt(i - 1)))
res += roman_char_dict.get(roman_numeral.charAt(i));
else
res += roman_char_dict.get(roman_numeral.charAt(i)) - 2 * roman_char_dict.get(roman_numeral.charAt(i - 1));
}
return res;
}
public static void main(String[] args) {
String roman_numeral_input = "MMXVIII";
int number_output = transform_roman_numeral_to_number(roman_numeral_input);
System.out.println("Roman numeral " + roman_numeral_input + " equal to:" + number_output);
}
}
-------------------
Roman numeral MMXVIII equal to:2018