我正在尝试将整数x
(0<=x<=3999) 转换为 Roman numeric y
。
我为此编写了代码,但是在运行时我不断收到错误消息。这段代码有什么问题?
C1=['','M','MM','MMM'];
C2=['','C','CC','CCC','D','DC','DCC','DCCC','CM'];
C3=['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC'];
C4=['','I','II','IV','V','VI','VII','VIII','IX'];
x=0;
for i4=1:4;
for i3=1:9;
for i2=1:9;
for i1=1:9;
if x==0
y='';
else
y=[C1{i4} C2{i3} C3{i2} C4{i1}];
x=x+1;
end
end
end
end
end