Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import "/math" for Int, Nums
|
||||
import "/sort" for Sort
|
||||
import "/fmt" for Fmt
|
||||
import "./math" for Int, Nums
|
||||
import "./sort" for Sort
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var isInteger = Fn.new { |n| n is Num && n.isInteger }
|
||||
|
||||
|
|
|
|||
54
Task/Heronian-triangles/XPL0/heronian-triangles.xpl0
Normal file
54
Task/Heronian-triangles/XPL0/heronian-triangles.xpl0
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
include xpllib; \for Min, GCD, StrSort, StrNCmp, and Print
|
||||
|
||||
func Hero(A, B, C); \Return area squared of triangle with sides A, B, C
|
||||
int A, B, C, S;
|
||||
[S:= (A+B+C)/2;
|
||||
if rem(0) = 1 then return 0; \return 0 if area is not an integer
|
||||
return S*(S-A)*(S-B)*(S-C);
|
||||
];
|
||||
|
||||
func Heronian(A, B, C); \Return area of triangle if sides and area are integers
|
||||
int A, B, C, Area2, Area;
|
||||
[Area2:= Hero(A, B, C);
|
||||
Area:= sqrt(Area2);
|
||||
return if Area*Area = Area2 then Area else 0;
|
||||
];
|
||||
|
||||
def MaxSide = 200;
|
||||
int A, B, C, Area, Count, I, J, K;
|
||||
char Array(1000, 5*5);
|
||||
[Format(5, 0);
|
||||
Count:= 0;
|
||||
for A:= 1 to MaxSide do
|
||||
for B:= A to MaxSide do
|
||||
for C:= B to Min(A+B-1, MaxSide) do
|
||||
if GCD(GCD(B,C), A) = 1 then
|
||||
[Area:= Heronian(A, B, C);
|
||||
if Area > 0 then
|
||||
[OpenO(8);
|
||||
RlOut(8, float(Area));
|
||||
RlOut(8, float(A+B+C));
|
||||
RlOut(8, float(C));
|
||||
RlOut(8, float(B));
|
||||
RlOut(8, float(A));
|
||||
OpenI(8);
|
||||
for I:= 0 to 25-1 do Array(Count,I):= ChIn(8);
|
||||
Count:= Count+1;
|
||||
];
|
||||
];
|
||||
Print("Count = %d\n", Count);
|
||||
StrSort(Array, Count);
|
||||
Print(" A B C Perim Area\n");
|
||||
for I:= 0 to 10-1 do
|
||||
[for J:= 4 downto 0 do
|
||||
Print("%5.5s", @Array(I, J*5+K));
|
||||
Print("\n");
|
||||
];
|
||||
Print("\n");
|
||||
for I:= 0 to Count-1 do
|
||||
if StrNCmp(" 210", @Array(I,0), 5) = 0 then
|
||||
[for J:= 4 downto 0 do
|
||||
Print("%5.5s", @Array(I, J*5+K));
|
||||
Print("\n");
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue