Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -0,0 +1,22 @@
|
|||
PRINT 1999;" ";FNint_ToRoman(1999)
|
||||
PRINT 2012;" ";FNint_ToRoman(2012)
|
||||
PRINT 1666;" ";FNint_ToRoman(1666)
|
||||
PRINT 3888;" ";FNint_ToRoman(3888)
|
||||
END
|
||||
DEFFNint_ToRoman(A%)
|
||||
IF A%<0:="MINIMUS"
|
||||
IF A%=0:="NULLA"
|
||||
IF A%>3999:="MAXIMUS"
|
||||
A$=STRING$(A% DIV 1000,"M"):A%=A% MOD 1000
|
||||
IF A%>899:A$=A$+"CM":A%=A%-900
|
||||
IF A%>499:A$=A$+"D" :A%=A%-500
|
||||
IF A%>399:A$=A$+"CD":A%=A%-400
|
||||
A$=A$+STRING$(A% DIV 100,"C"):A%=A% MOD 100
|
||||
IF A%>89:A$=A$+"XC":A%=A%-90
|
||||
IF A%>49:A$=A$+"L" :A%=A%-50
|
||||
IF A%>39:A$=A$+"XL":A%=A%-40
|
||||
A$=A$+STRING$(A% DIV 10,"X"):A%=A% MOD 10
|
||||
IF A%>8:A$=A$+"IX":A%=A%-9
|
||||
IF A%>4:A$=A$+"V" :A%=A%-5
|
||||
IF A%>3:A$=A$+"IV":A%=A%-4
|
||||
=A$+STRING$(A%,"I")
|
||||
30
Task/Roman-numerals-Encode/Draco/roman-numerals-encode.draco
Normal file
30
Task/Roman-numerals-Encode/Draco/roman-numerals-encode.draco
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
proc toroman(word n; *char buf) *char:
|
||||
*char parts = "M\e\eCM\eD\e\eCD\eC\e\eXC\eL\e\eXL\eX\e\eIX\eV\e\eIV\eI";
|
||||
[13]word sizes = (1000,900,500,400,100,90,50,40,10,9,5,4,1);
|
||||
channel output text roman;
|
||||
word part;
|
||||
|
||||
open(roman, buf);
|
||||
while n > 0 do
|
||||
part := 0;
|
||||
while sizes[part]>n do part := part+1 od;
|
||||
write(roman; parts + 3*part);
|
||||
n := n - sizes[part]
|
||||
od;
|
||||
close(roman);
|
||||
buf
|
||||
corp
|
||||
|
||||
proc test(word n) void:
|
||||
[32]char buf;
|
||||
writeln(n, ": ", toroman(n, &buf[0]))
|
||||
corp
|
||||
|
||||
proc main() void:
|
||||
test(1666);
|
||||
test(2008);
|
||||
test(1001);
|
||||
test(1999);
|
||||
test(3888);
|
||||
test(2025)
|
||||
corp
|
||||
31
Task/Roman-numerals-Encode/Refal/roman-numerals-encode.refal
Normal file
31
Task/Roman-numerals-Encode/Refal/roman-numerals-encode.refal
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
$ENTRY Go {
|
||||
= <Show 1666>
|
||||
<Show 2008>
|
||||
<Show 1001>
|
||||
<Show 1999>
|
||||
<Show 3888>
|
||||
<Show 2025>;
|
||||
};
|
||||
|
||||
Show {
|
||||
s.N = <Prout <Symb s.N> ' = ' <Roman s.N>>;
|
||||
};
|
||||
|
||||
Roman {
|
||||
0 = ;
|
||||
s.N, <RomanStep s.N>: s.Next e.Part = e.Part <Roman s.Next>;
|
||||
};
|
||||
|
||||
RomanStep {
|
||||
s.N = <RomanStep s.N <RomanDigits>>;
|
||||
s.N (s.Size e.Part) e.Parts, <Compare s.N <Sub s.Size 1>>: '+' =
|
||||
<Sub s.N s.Size> e.Part;
|
||||
s.N t.Part e.Parts = <RomanStep s.N e.Parts>;
|
||||
};
|
||||
|
||||
RomanDigits {
|
||||
= (1000 'M')
|
||||
( 900 'CM') ( 500 'D') ( 400 'CD') ( 100 'C')
|
||||
( 90 'XC') ( 50 'L') ( 40 'XL') ( 10 'X')
|
||||
( 9 'IX') ( 5 'V') ( 4 'IV') ( 1 'I');
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import "./roman" for Roman
|
||||
|
||||
for (n in [1990, 1666, 2008, 2020]) System.print(Roman.new(n))
|
||||
Loading…
Add table
Add a link
Reference in a new issue