"Go if"의 두 판 사이의 차이

(새 문서: ==개요== ;Go if <source lang='go' run> package main import ( "fmt" "math" ) func sqrt(x float64) string { if x < 0 { return sqrt(-x) + "i" } return fmt.Sprint(math.Sqrt(x)...)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
2번째 줄: 2번째 줄:
;Go if
;Go if


<source lang='go' run>
<syntaxhighlight lang='go' run>
package main
package main


20번째 줄: 20번째 줄:
fmt.Println(sqrt(2), sqrt(-4))
fmt.Println(sqrt(2), sqrt(-4))
}
}
</source>
</syntaxhighlight>


==참고==
==참고==

2020년 11월 2일 (월) 02:48 판

1 개요

Go if
package main

import (
	"fmt"
	"math"
)

func sqrt(x float64) string {
	if x < 0 {
		return sqrt(-x) + "i"
	}
	return fmt.Sprint(math.Sqrt(x))
}

func main() {
	fmt.Println(sqrt(2), sqrt(-4))
}

2 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}