RosettaCodeData/Task/Floyds-triangle/XPL0/floyds-triangle.xpl0
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

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);
]