Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/Sudan-function/CLU/sudan-function.clu
Normal file
43
Task/Sudan-function/CLU/sudan-function.clu
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
sudan = proc (n, x, y: int) returns (int)
|
||||
if n=0 then
|
||||
return(x + y)
|
||||
elseif y=0 then
|
||||
return(x)
|
||||
else
|
||||
k: int := sudan(n, x, y-1)
|
||||
return(sudan(n-1, k, k+y))
|
||||
end
|
||||
end sudan
|
||||
|
||||
table = proc (n, xs, ys: int) returns (string)
|
||||
ss: stream := stream$create_output()
|
||||
stream$putl(ss, "sudan(" || int$unparse(n) || ",x,y):")
|
||||
stream$puts(ss, " ")
|
||||
for x: int in int$from_to(0, xs)
|
||||
do stream$putright(ss, int$unparse(x), 5) end
|
||||
for y: int in int$from_to(0, ys) do
|
||||
stream$putl(ss, "")
|
||||
stream$putright(ss, int$unparse(y) || ":", 5)
|
||||
for x: int in int$from_to(0, xs)
|
||||
do stream$putright(ss, int$unparse(sudan(n, x, y)), 5) end
|
||||
end
|
||||
stream$putl(ss, "")
|
||||
return(stream$get_contents(ss))
|
||||
end table
|
||||
|
||||
show = proc (n, x, y: int) returns (string)
|
||||
return("sudan(" || int$unparse(n)
|
||||
|| ", " || int$unparse(x)
|
||||
|| ", " || int$unparse(y)
|
||||
|| ") = " || int$unparse(sudan(n,x,y)))
|
||||
end show
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
stream$putl(po, table(0, 6, 5))
|
||||
stream$putl(po, table(1, 6, 5))
|
||||
stream$putl(po, show(1, 3, 3))
|
||||
stream$putl(po, show(2, 1, 1))
|
||||
stream$putl(po, show(2, 2, 1))
|
||||
stream$putl(po, show(3, 1, 1))
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue