Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Roman-numerals-Encode/XPL0/roman-numerals-encode.xpl0
Normal file
25
Task/Roman-numerals-Encode/XPL0/roman-numerals-encode.xpl0
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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)];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue