This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Student struct { | |
name string | |
address string | |
grade int32 | |
phone [10]byte | |
id int8 | |
classID int8 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Student struct { | |
id int8 | |
name string | |
classID int8 | |
phone [10]byte | |
address string | |
grade int32 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Student struct { | |
id int8 // 1 byte | |
name string // 16 bytes | |
classID int8 // 1 byte | |
phone [10]byte // 10 bytes | |
address string // 16 bytes | |
grade int32 // 4 bytes | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct T2 { | |
f1 i8 | |
f3 i32 | |
f2 i64 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct T1 { | |
f1 i8 | |
_ [7]byte // 7 bytes padding | |
f2 i64 | |
f3 i32 | |
_ [4]byte // 4 bytes padding | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type T1 struct { | |
f1 int8 // 1 byte | |
f2 int64 // 8 bytes | |
f3 int32 // 4 bytes | |
} | |
func main() { | |
t1 := T1{} | |
fmt.Println(unsafe.Sizeof(t1)) // 24 bytes | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type T2 struct { | |
f1 int8 // 1 byte | |
f3 int32 // 4 bytes | |
f2 int64 // 8 bytes | |
} | |
func main() { | |
t2 := T2{} | |
fmt.Println(unsafe.Sizeof(t2)) // 16 bytes | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum_to_x(x) { | |
let sum = 0 | |
for(let i=0; i <= x; i++) { | |
sum += i | |
} | |
return sum | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loop_print2() { | |
for(let x = 0; x * x < 10000; x++) { | |
print(x) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loop_print() { | |
for(let i = 0; i < 100; i++){ | |
print(i * 500) | |
} | |
} |
NewerOlder