最赞回答 / 漠其世
package mainimport ( "fmt")func main() { map1 := map[int]string{1: "Golang", 2: "Java", 3: "Python", 4: "C"} for i:=1;i<5;i++{ fmt.Printf("%d: %s\n",i,map1[i]) }}加不加\n都行,看来老师是c党
2017-06-17
package main
import "fmt"
type Person struct {
Name string
Gender string
Age uint8
Address string
}
func (p *Person) Move(a string)string{
s:=p.Address
p.Address=a
return s
}
import "fmt"
type Person struct {
Name string
Gender string
Age uint8
Address string
}
func (p *Person) Move(a string)string{
s:=p.Address
p.Address=a
return s
}
2017-06-17
sum :=(numbers2[0]+numbers2[1]+numbers2[2]+numbers2[3]+numbers2[4])显然最好
2017-06-14
有bug,最后只能
fmt.Printf("Error: open //datadata/webroot/index.go: no such file or directory\n")
fmt.Printf("The content of '%s':\n%s\n", path, ba)
这样通过.....
fmt.Printf("Error: open //datadata/webroot/index.go: no such file or directory\n")
fmt.Printf("The content of '%s':\n%s\n", path, ba)
这样通过.....
2017-06-14
func main() {
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4) + 1]; interface{}(v).(type) {
case string, uint, int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
ia := []interface{}{byte(6), 'a', uint(10), int32(-4)}
switch v := ia[rand.Intn(4) + 1]; interface{}(v).(type) {
case string, uint, int32 :
fmt.Printf("Case A.")
case byte :
fmt.Printf("Case B.")
default:
fmt.Println("Unknown!")
}
}
2017-06-14
type Cat struct {
Name string
Age int
Place string
}
func (c *Cat) Grow() {
c.Age ++
}
func (c *Cat) Move(newPlace string) string {
oldPlace := c.Place
c.Place = newPlace
return oldPlace
}
Name string
Age int
Place string
}
func (c *Cat) Grow() {
c.Age ++
}
func (c *Cat) Move(newPlace string) string {
oldPlace := c.Place
c.Place = newPlace
return oldPlace
}
2017-06-14
func (person *Person) Move(newAddress string) string {
oldAddress := person.Address
person.Address = newAddress
return oldAddress
}
oldAddress := person.Address
person.Address = newAddress
return oldAddress
}
2017-06-13