-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path03_inc_dec.go
52 lines (42 loc) · 1.05 KB
/
03_inc_dec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Sedmá část
// Programovací jazyk Go: dokončení popisu vlastností samotného jazyka
// https://www.root.cz/clanky/programovaci-jazyk-go-dokonceni-popisu-vlastnosti-samotneho-jazyka/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů ze sedmé části:
// https://github.com/tisnik/go-root/blob/master/article_07/README.md
//
// Demonstrační příklad číslo 3:
// Operátory ++ a --.
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_07/03_inc_dec.html
package main
import "fmt"
func main() {
x := 1
fmt.Printf("x = %d\n", x)
x++
fmt.Printf("x = %d\n", x)
x--
fmt.Printf("x = %d\n", x)
px := &x
fmt.Printf("x = %d\n", *px)
*px++
fmt.Printf("x = %d\n", *px)
*px--
fmt.Printf("x = %d\n", *px)
y := 3.14
fmt.Printf("y = %f\n", y)
y++
fmt.Printf("y = %f\n", y)
z := 1 + 2i
fmt.Printf("z = %f\n", z)
z++
fmt.Printf("z = %f\n", z)
}