|
@@ -0,0 +1,63 @@
|
|
|
|
|
+package main
|
|
|
|
|
+
|
|
|
|
|
+import (
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+func main() {
|
|
|
|
|
+ foo1()
|
|
|
|
|
+ /*
|
|
|
|
|
+ value1, value2, operation := readTask()
|
|
|
|
|
+
|
|
|
|
|
+ switch v1 := value1.(type) {
|
|
|
|
|
+ case float64:
|
|
|
|
|
+ break
|
|
|
|
|
+ default:
|
|
|
|
|
+ fmt.Printf("value=%v: %T\n", v1, v1)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ switch v2 := value2.(type) {
|
|
|
|
|
+ case float64:
|
|
|
|
|
+ break
|
|
|
|
|
+ default:
|
|
|
|
|
+ fmt.Printf("value=%v: %T\n", v2, v2)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ switch op := operation.(type) {
|
|
|
|
|
+ case string:
|
|
|
|
|
+ if op == "+" {
|
|
|
|
|
+ fmt.Printf("%.4f\n", value1.(float64)+value2.(float64))
|
|
|
|
|
+ } else if op == "-" {
|
|
|
|
|
+ fmt.Printf("%.4f\n", value1.(float64)-value2.(float64))
|
|
|
|
|
+ } else if op == "*" {
|
|
|
|
|
+ fmt.Printf("%.4f\n", value1.(float64)*value2.(float64))
|
|
|
|
|
+ } else if op == "/" {
|
|
|
|
|
+ fmt.Printf("%.4f\n", value1.(float64)/value2.(float64))
|
|
|
|
|
+ }
|
|
|
|
|
+ default:
|
|
|
|
|
+ fmt.Printf("operation=%v: %T\n", op, op)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // fmt.Println("value 1 - OK")
|
|
|
|
|
+ // fmt.Println(value1, value2, operation)
|
|
|
|
|
+ */
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func foo1() {
|
|
|
|
|
+ // vi1, vi2, operation := readTask()
|
|
|
|
|
+ // vi := [2]interface{}{vi1, vi2}
|
|
|
|
|
+ var v1, v2 float64
|
|
|
|
|
+ vf := [2]*float64{&v1, &v2}
|
|
|
|
|
+ fmt.Println(vf)
|
|
|
|
|
+ fmt.Printf("%v %T", vf, vf)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func readTask() (v1, v2, op interface{}) {
|
|
|
|
|
+ v1 = 12.36
|
|
|
|
|
+ v2 = 36.24
|
|
|
|
|
+ op = "+"
|
|
|
|
|
+ return
|
|
|
|
|
+}
|