24 lines
565 B
Text
24 lines
565 B
Text
include c:\cxpl\codes; \include 'code' declarations
|
|
|
|
func IntLen(N); \Return number of digits in a positive integer
|
|
int N;
|
|
int I;
|
|
for I:= 1 to 20 do
|
|
[N:= N/10; if N=0 then return I];
|
|
|
|
proc Floyd(N); \Display Floyd's triangle
|
|
int N;
|
|
int M, Row, Col;
|
|
real F;
|
|
[M:= (N-1+1)*(N-1)/2; \last Floyd number on second to last row
|
|
F:= 1.0; \Floyd number counter
|
|
for Row:= 1 to N do
|
|
[for Col:= 1 to Row do
|
|
[Format(IntLen(M+Col)+1, 0); RlOut(0, F); F:= F+1.0];
|
|
CrLf(0);
|
|
];
|
|
]; \Floyd
|
|
|
|
[Floyd(5);
|
|
Floyd(14);
|
|
]
|