首次提交:初始化项目代码

This commit is contained in:
sunct
2026-07-31 15:18:32 +08:00
commit d6393266b0
193 changed files with 14287 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package main
import "fmt"
func main() {
var isSuccess bool
fmt.Printf("布尔零值: %t\n", isSuccess) // 输出false
a, b := true, false
// 逻辑运算
fmt.Printf("a && b: %t\n", a && b) // false(与)
fmt.Printf("a || b: %t\n", a || b) // true(或)
fmt.Printf("!a: %t\n", !a) // false(非)
// 条件判断中使用
score := 85
isPass := score >= 60
if isPass {
fmt.Println("考试通过") // 输出此句
}
// 错误示例(编译不通过)
// var b bool = 1 // 报错:cannot use 1 (untyped int constant) as bool value in variable declaration
// fmt.Println(b + 1) // 报错:invalid operation: b + 1 (mismatched types bool and untyped int)
}