package main
import "fmt"
func main() {
/* sayLove2Golang()
sayLove2SB("拉芳")*/
/* sayLoveToSb2("拉芳",5)*/
/* saLoveToThem("拉芳","拉草","潘婷")*/
sayLoveToSb3("王彦","彦虎",5)
}
func sayLove2Golang() {
fmt.Println("人生苦短,我学go")
fmt.Println("此时不浪,更待何时")
fmt.Println("3333")
fmt.Println("4444")
}
func sayLoveTSB(name string) {
fmt.Println("人生苦短,必须学习")
fmt.Printf("我**你,%s\n",name)
}
func sayLoveToSb2(name string,n int) {
fmt.Println("人生苦短,必须学习")
for i:= 0 ; i < n ; i++ {
fmt.Printf("我**你,%s\n",name)
}
}
/*不定长参数:类型为切片容器*/
func saLoveToThem(names ...string) {
fmt.Println("人生苦短,必须学习")
/* fmt.Printf("我*%s\n",names)
*/ for i, name := range(names){
fmt.Printf("我爱No.%d: %s\n",i,name)
}
}
func sayLoveToSb3(name1 ,name2 string, n int) {
fmt.Println("人生苦短,必须学习")
for i := 0; i < n ; i++ {
fmt.Printf("我爱%s\n", name1)
fmt.Printf("我爱%s\n", name2)
}
}
网友评论