```
// task1 project main.go
package main
import (
"fmt"
"math/big"
//"os"
//"strconv"
)
//var b [64]big.Rat
func GFS(z [64]big.Rat, c big.Rat, y [6]uint, w [6]uint, count uint) {
var temp big.Rat
switch count {
case 0:
if y[0] == 1 && y[1] == 1 {
temp.Mul(&c, big.NewRat(14, 15))
w[1] = 1
GFS(z, temp, y, w, 1+count)
temp.Mul(&c, big.NewRat(1, 15))
w[1] = 0
GFS(z, temp, y, w, 1+count)
} else {
w[1] = y[1]
GFS(z, c, y, w, 1+count)
}
case 1:
if y[2] == 1 && y[3] == 1 {
temp.Mul(&c, big.NewRat(14, 15))
w[3] = 1
GFS(z, temp, y, w, 1+count)
temp.Mul(&c, big.NewRat(1, 15))
w[3] = 0
GFS(z, temp, y, w, 1+count)
} else {
w[3] = y[3]
GFS(z, c, y, w, 1+count)
}
case 2:
if y[4] == 1 && y[5] == 1 {
temp.Mul(&c, big.NewRat(14, 15))
w[5] = 1
GFS(z, temp, y, w, 1+count)
temp.Mul(&c, big.NewRat(1, 15))
w[5] = 0
GFS(z, temp, y, w, 1+count)
} else {
w[5] = y[5]
GFS(z, c, y, w, 1+count)
}
case 3:
var m uint
for i := uint(0); i < 6; i++ {
m += w[i] << i
}
temp.Mul(&c, big.NewRat(1, 63))
z[m].Add(&z[m], &temp)
default:
break
}
}
func main() {
var z [64]big.Rat
var y [6]uint
var w [6]uint
var c = *big.NewRat(1, 1)
for i := 1; i < 64; i++ {
z[i] = *big.NewRat(0, 1)
}
for i := uint(1); i < 64; i++ {
y[0] = i & 0x1
y[1] = i & 0x2 >> 1
y[2] = i & 0x4 >> 2
y[3] = i & 0x8 >> 3
y[4] = i & 0x16 >> 4
y[5] = i & 0x32 >> 5
w[0] = y[0]
w[2] = y[2]
w[4] = y[4]
GFS(z, c, y, w, 0)
}
for i := 0; i < 64; i++ {
fmt.Printf(z[i].String())
fmt.Println()
}
}
```
为什么结果输出是这样,Z[64]的值都为我设的初始值
![TIM图片20180820094204.png](https://static.studygolang.com/180820/a2b5934c16b5571b9051fe72e53b3c6c.png)
有疑问加站长微信联系(非本文作者)