Skip to content

Instantly share code, notes, and snippets.

@jiaqi-yin
Created June 8, 2021 13:53
Show Gist options
  • Save jiaqi-yin/7bcb179de173a10658996a1ea12c48c4 to your computer and use it in GitHub Desktop.
Save jiaqi-yin/7bcb179de173a10658996a1ea12c48c4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func main() {
var row int = 10
for i := 1; i <= row; i++ {
for k := 0; k < row-i; k++ {
fmt.Print(" ")
}
for j := 1; j <= 2*i-1; j++ {
if (j == 1 || j == 2*i-1) || i == row {
fmt.Print("*")
} else {
fmt.Print(" ")
}
}
fmt.Println("")
}
}
/* Output:
*
* *
* *
* *
* *
* *
* *
* *
* *
*******************
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment