码迷,mamicode.com
首页 > 其他好文 > 详细

3.9

时间:2018-03-22 01:43:03      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:diff   fine   ack   number   sum   ber   UNC   AC   efi   


package main

import (
    "fmt"
    "math/cmplx"
)

func main() {

    // complex numbers are
    // defined as real and imaginary
    // part defined by float64
    a := complex(2, 3)

    fmt.Printf("Real part: %f \n", real(a))
    fmt.Printf("Complex part: %f \n", imag(a))

    b := complex(6, 4)

    // All common
    // operators are useful
    c := a - b
    fmt.Printf("Difference : %v\n", c)
    c = a + b
    fmt.Printf("Sum : %v\n", c)
    c = a * b
    fmt.Printf("Product : %v\n", c)
    c = a / b
    fmt.Printf("Product : %v\n", c)

    conjugate := cmplx.Conj(a)
    fmt.Println("Complex number a‘s conjugate : ", conjugate)

    cos := cmplx.Cos(b)
    fmt.Println("Cosine of b : ", cos)

}

/*
package main

import (
    "fmt"
    "math/cmplx"
)

func main() {

    // complex numbers are
    // defined as real and imaginary
    // part defined by float64
    a := complex(2, 3)

    fmt.Printf("Real part: %f \n", real(a))
    fmt.Printf("Complex part: %f \n", imag(a))

    b := complex(6, 4)

    // All common
    // operators are useful
    c := a - b
    fmt.Printf("Difference : %v\n", c)
    c = a + b
    fmt.Printf("Sum : %v\n", c)
    c = a * b
    fmt.Printf("Product : %v\n", c)
    c = a / b
    fmt.Printf("Product : %v\n", c)

    conjugate := cmplx.Conj(a)
    fmt.Println("Complex number a‘s conjugate : ", conjugate)

    cos := cmplx.Cos(b)
    fmt.Println("Cosine of b : ", cos)

}

*/

3.9

标签:diff   fine   ack   number   sum   ber   UNC   AC   efi   

原文地址:https://www.cnblogs.com/zrdpy/p/8620796.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!