golang-exercises/star-shapes/shapes.go

35 lines
517 B
Go
Raw Normal View History

package main
import "fmt"
// Drawing a line of asterisks
func line(num int) {
for i := 0; i < num; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
// Drawing a square of asterisks
func square(num int) {
for i := 0; i < num; i++ {
for i := 0; i < num; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
}
// Drawing a flag of asterisks
func flag(num int) {
for a := 0; a < num; a++ {
for i := -1; i < a; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
for i := 0; i < num/2; i++ {
println("*")
}
}