Roman numeral by uru

var a:array[0..12]of
word=(900,1000,400,500,90,100,40,50,9,10,4,5,1);b:array[0..12]of
string=("CM","M","CD","D","XC","C","XL","L","IX","X","IV","V","I");s:string;i,n:word;begin
repeat
readln(s);n:=0;repeat
for i:=0to 12do if pos(b[i],s)>0then begin
n:=n+a[i];delete(s,pos(b[i],s),length(b[i]))end
until""=s;writeln(n)until 1=0end.

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page