1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| package main
import "fmt"
func main(){
printstring() add(2,4)
fmt.Println("addres 6+7 = ",addres(6,7)) fmt.Println("addresname 3+4 = ",addresname(3,4))
add,sum :=addmuti(5,6) fmt.Printf("addmuti 5+6=%d,5*6=%d\n",add,sum)
ADDsum := addsum(1,2,3,4,5) fmt.Println("addsum = ",ADDsum) }
func printstring(){ fmt.Println("hello jonson") }
func add(a,b int){ fmt.Println("a+b=",a+b) }
func addres(a,b int) int{ return a+b }
func addresname(a,b int)(sum int){ sum = a+b return }
func addmuti(a,b int)(int,int){ add := a+b mul:= a*b
return add,mul }
func addsum(nums ... int) int{ var sum int for _,value :=range nums{ sum +=value } return sum }
|