Número arabigo de número romano en Groovy

/** *<h1>Obtener número arabigo de número romano</h1> *@author Fer Carraro *@date 08-03-015 */ static main(args) { int arabigo=0 def romanos=["I": 1, "V": 5,"X": 10,"L": 50,"C": 100,"D": 500,"M": 1000] def romano="LX" println "Número romano: $romano" for(int i=0; i < romano.length(); i++){ if( romano[i] instanceof String){ //println romano[i]+" posicion: $i, numero arabigo:"+romanos[romano[i]] arabigo= arabigo + romanos[romano[i]] } } println "Número arabigo: $arabigo" }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.