Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
39
Task/Cantor-set/Go/cantor-set.go
Normal file
39
Task/Cantor-set/Go/cantor-set.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
width = 81
|
||||
height = 5
|
||||
)
|
||||
|
||||
var lines [height][width]byte
|
||||
|
||||
func init() {
|
||||
for i := 0; i < height; i++ {
|
||||
for j := 0; j < width; j++ {
|
||||
lines[i][j] = '*'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cantor(start, len, index int) {
|
||||
seg := len / 3
|
||||
if seg == 0 {
|
||||
return
|
||||
}
|
||||
for i := index; i < height; i++ {
|
||||
for j := start + seg; j < start + 2 * seg; j++ {
|
||||
lines[i][j] = ' '
|
||||
}
|
||||
}
|
||||
cantor(start, seg, index + 1)
|
||||
cantor(start + seg * 2, seg, index + 1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
cantor(0, width, 1)
|
||||
for _, line := range lines {
|
||||
fmt.Println(string(line[:]))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue