Skip to content

Commit 8f799d4

Browse files
author
maxcook
committed
Update on Readme
1 parent 3354299 commit 8f799d4

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

exercises/day01/hello_world.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Day 01 - Hello World 练习
2-
// 日期: 2024年1月 (请根据实际日期修改)
2+
// 日期: 2025年x月 (请根据实际日期修改)
33
// 学习内容: Go语言基础语法入门
44

55
package main
@@ -11,16 +11,11 @@ func main() {
1111
fmt.Println("=== Day 01: Hello World 练习 ===")
1212
fmt.Println("Hello, World!")
1313
fmt.Println("你好,Go语言!")
14-
14+
1515
// 变量练习
1616
name := "Go学习者"
1717
day := 1
1818
fmt.Printf("我是%s,今天是第%d天学习Go语言\n", name, day)
19-
20-
// 简单计算
21-
a, b := 10, 20
22-
sum := a + b
23-
fmt.Printf("%d + %d = %d\n", a, b, sum)
24-
19+
2520
fmt.Println("今天的学习完成!✅")
26-
}
21+
}
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Day 02 - 变量和类型练习
2-
// 日期: 2024年1月 (请根据实际日期修改)
2+
// 日期: 2025年x月 (请根据实际日期修改)
33
// 学习内容: 变量声明、基本类型、类型转换
44

55
package main
@@ -8,13 +8,35 @@ import "fmt"
88

99
func main() {
1010
fmt.Println("=== Day 02: 变量和类型练习 ===")
11-
11+
1212
// TODO: 在这里完成今天的练习
1313
// 1. 声明不同类型的变量
14+
var name string = "go 语言爱好者"
15+
var age int = 25
16+
var isStudnet bool = false
17+
fmt.Printf("姓名:%s, 年龄:%d, 是否学生:%v\n", name, age, isStudnet)
18+
19+
//短变量声明(只能在函数内使用)
20+
day := 2
21+
year := 2025
22+
version := "v1.0.0"
23+
fmt.Printf("今天是第 %d 天练习,%d年, 版本号为:%s\n", day, year, version)
24+
25+
//基本数据类型
26+
var int8Val int8 = 127
27+
28+
// 浮点类型
29+
var float32Val float32 = 3.141592653589793
30+
var float64Val float64 = 3.141592653589793
31+
32+
fmt.Printf("整数类型: %d\n", int8Val)
33+
fmt.Printf("float32浮点类型: %f\n", float32Val)
34+
fmt.Printf("float64浮点类型: %f\n", float64Val)
35+
1436
// 2. 练习类型转换
1537
// 3. 使用常量
1638
// 4. 数组和切片操作
17-
39+
1840
fmt.Println("今天的练习: 变量和类型")
1941
fmt.Println("请完成上面的TODO项目")
20-
}
42+
}

0 commit comments

Comments
 (0)