Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Sierpinski-carpet/VBScript/sierpinski-carpet.vb
Normal file
32
Task/Sierpinski-carpet/VBScript/sierpinski-carpet.vb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
Function InCarpet(i,j)
|
||||
If i > 0 And j > 0 Then
|
||||
Do While i > 0 And j > 0
|
||||
If i Mod 3 = 1 And j Mod 3 = 1 Then
|
||||
InCarpet = " "
|
||||
Exit Do
|
||||
Else
|
||||
InCarpet = "#"
|
||||
End If
|
||||
i = Int(i / 3)
|
||||
j = Int(j / 3)
|
||||
Loop
|
||||
Else
|
||||
InCarpet = "#"
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function Carpet(n)
|
||||
k = 3^n - 1
|
||||
x2 = 0
|
||||
y2 = 0
|
||||
For y = 0 To k
|
||||
For x = 0 To k
|
||||
x2 = x
|
||||
y2 = y
|
||||
WScript.StdOut.Write InCarpet(x2,y2)
|
||||
Next
|
||||
WScript.StdOut.WriteBlankLines(1)
|
||||
Next
|
||||
End Function
|
||||
|
||||
Carpet(WScript.Arguments(0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue