Last active
March 9, 2018 16:04
-
-
Save AsafFisher/9f37c5bebeabea6445929f389e5918e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.TreeMap; | |
public class MyClass { | |
static TreeMap<Integer, String> a = new TreeMap<Integer, String>();public static void main(String args[]) {a.put(1000, "M");a.put(900, "CM");a.put(500, "D");a.put(400, "CD");a.put(100, "C");a.put(90, "XC");a.put(50, "L");a.put(40, "XL");a.put(10, "X");a.put(9, "IX");a.put(5, "V");a.put(4, "IV");a.put(1, "I");System.out.print(b(44));}static String b(int n){int n1=a.floorKey(n);if(n==n1)return a.get(n);return(a.get(n1) + b(n-n1));} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment