Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Sierpinski-carpet/Relation/sierpinski-carpet.relation
Normal file
35
Task/Sierpinski-carpet/Relation/sierpinski-carpet.relation
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
function incarpet(x,y)
|
||||
set a = x
|
||||
set b = y
|
||||
while floor(a)>0 and floor(b)>0
|
||||
if floor(a mod 3) = 1 and floor(b mod 3) = 1
|
||||
set a = -1
|
||||
set b = -1
|
||||
else
|
||||
set a = a / 3
|
||||
set b = b / 3
|
||||
end if
|
||||
end while
|
||||
if a < 0
|
||||
set result = "_"
|
||||
else
|
||||
set result = "#"
|
||||
end if
|
||||
end function
|
||||
|
||||
program carpet(n)
|
||||
set d = pow(3,n)
|
||||
set y = 0
|
||||
while y < d
|
||||
set x = 0
|
||||
set result = " "
|
||||
while x < d
|
||||
set result = result . incarpet(x,y)
|
||||
set x = x + 1
|
||||
end while
|
||||
echo result
|
||||
set y = y + 1
|
||||
end while
|
||||
end program
|
||||
|
||||
run carpet(3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue