func funcs(n1 float64, n2 float64, operator byte) float64{ var res float64 switch operator { case '+': res = n1 + n2 case '*': res = n1 * n2 case '-': res = n1 - n2 default: fmt.Printf("输入error !!\n") } return res //返回函数计算结果 } func test (x int) { x = x + 1 fmt.Printf("x=%d\n",x) } func main() { n1 := 3.3 n2 := 3.9 x := 10 var operator byte = '+' res := funcs(n1,n2,operator) //接收函数计算结果 fmt.Printf("计算结果等于: %.2v\n",res) //输出计算结果 test(x) fmt.Println(x) }