-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiramides_asteriscos_closuresI.go
66 lines (56 loc) · 1.05 KB
/
piramides_asteriscos_closuresI.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import "fmt"
func main() {
var num, esp, lin, limit2 int
var ImprInterior func()
limit2 = 2
fmt.Println("ingrese un numero")
fmt.Scan(&num)
if num%2 == 0 {
lin = num / 2 //num lineas
} else {
lin = num/2 + 1
}
esp = lin - 1 //arrobas
//probando clausuras-----------------------------------
ImprPiramide := func() {
for i := 0; i < esp; i++ {
fmt.Print(" ")
}
if num%2 == 0 { //num pares
fmt.Println("**")
} else { //num impares
fmt.Println("*")
}
ImprInterior = func() {
if esp > 1 {
limit := esp
for i := 0; i < limit-1; i++ {
fmt.Print(" ")
}
fmt.Print("*")
if num%2 == 0 {
for i := 0; i < limit2; i++ {
fmt.Print("@")
}
fmt.Println("*")
} else {
for i := 0; i < limit2-1; i++ {
fmt.Print("@")
}
fmt.Println("*")
}
limit2 += 2
esp--
ImprInterior()
}
}
ImprInterior()
for i := 0; i < num; i++ {
fmt.Print("*")
}
fmt.Println()
}
//---------------------------------------------------------
ImprPiramide()
}