zoukankan      html  css  js  c++  java
  • 3.9

    
    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 
    ", real(a))
    	fmt.Printf("Complex part: %f 
    ", imag(a))
    
    	b := complex(6, 4)
    
    	// All common
    	// operators are useful
    	c := a - b
    	fmt.Printf("Difference : %v
    ", c)
    	c = a + b
    	fmt.Printf("Sum : %v
    ", c)
    	c = a * b
    	fmt.Printf("Product : %v
    ", c)
    	c = a / b
    	fmt.Printf("Product : %v
    ", 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 
    ", real(a))
    	fmt.Printf("Complex part: %f 
    ", imag(a))
    
    	b := complex(6, 4)
    
    	// All common
    	// operators are useful
    	c := a - b
    	fmt.Printf("Difference : %v
    ", c)
    	c = a + b
    	fmt.Printf("Sum : %v
    ", c)
    	c = a * b
    	fmt.Printf("Product : %v
    ", c)
    	c = a / b
    	fmt.Printf("Product : %v
    ", c)
    
    	conjugate := cmplx.Conj(a)
    	fmt.Println("Complex number a's conjugate : ", conjugate)
    
    	cos := cmplx.Cos(b)
    	fmt.Println("Cosine of b : ", cos)
    
    }
    
    */
    
    
  • 相关阅读:
    201. Bitwise AND of Numbers Range
    200.Number of Islands
    199. Binary Tree Right Side View
    198. House Robber
    191. Number of 1 Bits
    190. Reverse Bits
    odoo pivot filed字段设置
    postgres 实现查找所有的子记录,child_of
    postgres 查询返回记录集的函数
    python GUI编程/窗口编程之easygui
  • 原文地址:https://www.cnblogs.com/zrdpy/p/8620796.html
Copyright © 2011-2022 走看看