GP42. 学生信息II
描述
输入描述
无输出描述
Go 解法, 执行用时: 2ms, 内存消耗: 1132KB, 提交时间: 2022-07-27
package main import ( "fmt" ) type stu struct { name string sex bool age int score int } func main() { a := stu{ name: "小明", age: 23, sex: true, score: 88, } fmt.Println(a.name) fmt.Println(a.sex) fmt.Println(a.age) fmt.Println(a.score) }
Go 解法, 执行用时: 2ms, 内存消耗: 1184KB, 提交时间: 2022-06-03
package main import ( "fmt" ) type Student struct { name string sex bool age int score int } func main() { stu := Student{"小明", true, 23, 88} fmt.Println(stu.name) fmt.Println(stu.sex) fmt.Println(stu.age) fmt.Println(stu.score) }
Go 解法, 执行用时: 2ms, 内存消耗: 1188KB, 提交时间: 2022-06-17
package main import ( "fmt" ) // 结构体定义 type student struct { name string sex bool age int score int } func main() { // 结构体的初始化 xiaoming := student { name: "小明", sex: true, age: 23, score: 88, } fmt.Println(xiaoming.name) fmt.Println(xiaoming.sex) fmt.Println(xiaoming.age) fmt.Println(xiaoming.score) }
Go 解法, 执行用时: 2ms, 内存消耗: 1204KB, 提交时间: 2022-07-11
package main import ( "fmt" ) type Student struct{ name string sex bool age int score int } func main() { a:=Student{ name:"小明", age:23, sex:true, score:88, } fmt.Println(a.name) fmt.Println(a.sex) fmt.Println(a.age) fmt.Println(a.score) }
Go 解法, 执行用时: 2ms, 内存消耗: 1320KB, 提交时间: 2022-06-08
package main import ( "fmt" ) type Student struct{ name string sex bool age int score int } func main() { s := Student{ name: "小明", sex:true, age:23, score:88, } fmt.Println(s.name) fmt.Println(s.sex) fmt.Println(s.age) fmt.Println(s.score) }