26 lines
827 B
Plaintext
26 lines
827 B
Plaintext
proc Rom(N, A, B, C); \Display 1..9 in Roman numerals
|
|
int N, A, B, C, I;
|
|
[case N of
|
|
9: [ChOut(0, C); ChOut(0, A)]; \XI
|
|
8,7,6,5:[ChOut(0, B); for I:= 1 to rem(N/5) do ChOut(0, C)]; \V
|
|
4: [ChOut(0, C); ChOut(0, B)] \IV
|
|
other for I:= 1 to N do ChOut(0, C); \I
|
|
];
|
|
|
|
proc Roman(N); \Display N in Roman numerals
|
|
int N, Q;
|
|
[Q:= N/1000; N:= rem(0); \0..3999
|
|
Rom(Q, ^?, ^?, ^M);
|
|
Q:= N/100; N:= rem(0); \0..999
|
|
Rom(Q, ^M, ^D, ^C);
|
|
Q:= N/10; N:= rem(0); \0..99
|
|
Rom(Q, ^C, ^L, ^X);
|
|
Rom(N, ^X, ^V, ^I); \0..9
|
|
];
|
|
|
|
int Tbl, I;
|
|
[Tbl:= [1990, 2008, 1666, 0, 1, 3999, 2020, 1234];
|
|
for I:= 0 to 7 do
|
|
[IntOut(0, Tbl(I)); Text(0, ". "); Roman(Tbl(I)); CrLf(0)];
|
|
]
|