Public class solution {Public String inttoroman (INT num) {stringbuffer result = new stringbuffer (); int n = num; // The variable was written incorrectly when the Code was first written, I don't want to change the while (n> 0) {If (n> = 1000) {result. append ('M'); N-= 1000;} else if (N >=900) {result. append ('C'); N + = 100;} else if (n> = 500) {result. append ('D'); N-= 500;} else if (n> = 400) {result. append ('C'); N + = 100;} else if (n> = 100) {result. append ('C'); N-= 100;} else if (n> = 90) {result. append ('x'); N + = 10;} else if (n> = 50) {result. append ('l'); N-= 50;} else if (n> = 40) {result. append ('x'); N + = 10;} else if (n> = 10) {result. append ('x'); N-= 10;} else if (n> = 9) {result. append ('I'); N + = 1;} else if (n> = 5) {result. append ('V'); N-= 5;} else if (n> = 4) {result. append ('I'); N + = 1;} else {result. append ('I'); N-= 1 ;}} return result. tostring ();}}
[Leetcode] integer to Roman