Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Pascals-triangle/XPL0/pascals-triangle.xpl0
Normal file
22
Task/Pascals-triangle/XPL0/pascals-triangle.xpl0
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
include c:\cxpl\codes;
|
||||
|
||||
proc Pascal(N); \Display the first N rows of Pascal's triangle
|
||||
int N; \if N<=0 then nothing is displayed
|
||||
int Row, I, Old(40), New(40);
|
||||
[for Row:= 0 to N-1 do
|
||||
[New(0):= 1;
|
||||
for I:= 1 to Row do New(I):= Old(I-1) + Old(I);
|
||||
for I:= 1 to (N-Row-1)*2 do ChOut(0, ^ );
|
||||
for I:= 0 to Row do
|
||||
[if New(I)<100 then ChOut(0, ^ );
|
||||
IntOut(0, New(I));
|
||||
if New(I)<10 then ChOut(0, ^ );
|
||||
ChOut(0, ^ );
|
||||
];
|
||||
New(Row+1):= 0;
|
||||
I:= Old; Old:= New; New:= I;
|
||||
CrLf(0);
|
||||
];
|
||||
];
|
||||
|
||||
Pascal(13)
|
||||
Loading…
Add table
Add a link
Reference in a new issue