close
import java.util.*;
public class test16
{
public static void main(String[] args)
{
int a, number, tenten, fifty, ten, five, n;
int done = 0, ften = 0, dten = 0, dtenten = 0, tfifty = 0;
String out = "";
System.out.println("請輸入一個數");
Scanner x = new Scanner(System.in);
a = number = x.nextInt();
tenten = number/100;
number = number%100;
fifty = number/50;
number = number%50;
ten = number/10;
number = number%10;
five = number/5;
number = number%5;
if (number == 4)
{
number = 0;
done = 1;
five = five + 1;
}
if (five == 2)
{
five = 0;
ften = 1;
}
if (ten == 5)
{
ten = 0;
fifty = fifty + 1;
}
else if (ten + ften == 5)
{
ten = 0;
ften = 0;
tfifty = 1;
}
if (fifty == 2)
{
fifty = 0;
dtenten = 1;
}
for(n =1;n<=dtenten;n++)
out = out +"X";
for(n =1;n<=tenten;n++)
out = out +"C";
for(n =1;n<=dten;n++)
out = out +"X";
for(n =1;n<=fifty;n++)
out = out +"L";
for(n =1;n<=ten;n++)
out = out +"X";
for(n =1;n<=done;n++)
out = out +"I";
for(n =1;n<=tfifty;n++)
out = out +"L";
for(n =1;n<=ften;n++)
out = out +"X";
for(n =1;n<=five;n++)
out = out +"V";
for(n =1;n<=number;n++)
out = out +"I";
System.out.println(out);
}
}
全站熱搜
留言列表