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)
    
    }
    
    */
    
    
  • 相关阅读:
    解决phpmailer可以在windows下面发送成功, 在linux下面失败的问题
    centos安装svn
    linux下面配置安装nodejs+npm
    排序与搜索
    链表
    栈和队列
    顺序表
    初识算法、数据结构
    Linux_02
    Linux_01
  • 原文地址:https://www.cnblogs.com/zrdpy/p/8620796.html
Copyright © 2011-2022 走看看