Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Floyds-triangle/CLU/floyds-triangle.clu
Normal file
32
Task/Floyds-triangle/CLU/floyds-triangle.clu
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
floyd = cluster is triangle
|
||||
rep = null
|
||||
|
||||
width = proc (n: int) returns (int)
|
||||
w: int := 1
|
||||
while n >= 10 do
|
||||
w := w + 1
|
||||
n := n / 10
|
||||
end
|
||||
return (w)
|
||||
end width
|
||||
|
||||
triangle = proc (rows: int) returns (string)
|
||||
ss: stream := stream$create_output()
|
||||
maxno: int := rows * (rows+1)/2
|
||||
num: int := 1
|
||||
for row: int in int$from_to(1, rows) do
|
||||
for col: int in int$from_to(1, row) do
|
||||
stream$putright(ss, int$unparse(num), 1 + width(maxno-rows+col))
|
||||
num := num + 1
|
||||
end
|
||||
stream$putl(ss, "")
|
||||
end
|
||||
return (stream$get_contents(ss))
|
||||
end triangle
|
||||
end floyd
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
stream$putl(po, floyd$triangle(5))
|
||||
stream$putl(po, floyd$triangle(14))
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue