两种拜占庭算法

方法一:

package mainimport ( "fmt" "time" ) var ch = make(chanstring) var t=[4]int{1}func aa(cnt int){ for i:=0; i<4; i++{ if i!=cnt { t[i] = t[cnt]+t[i] fmt.Println(t) } } } func main() { fmt.Println(t) go func () { cnt:=0 for { msg:=<-ch fmt.Println(msg) aa(cnt) } }() go func() { time.Sleep(time.Second) ch<-"1" }()for {} }

【两种拜占庭算法】方法二:
package mainimport "fmt"type Node struct { name string data int }var n = [4]Node{ Node{"N0", 0}, Node{"N1", 0}, Node{"N2", 0}, Node{"N3", 0}, }func main() { n[0].data = https://www.it610.com/article/1for i:=0; i

    推荐阅读