Created
June 8, 2021 13:53
-
-
Save jiaqi-yin/7bcb179de173a10658996a1ea12c48c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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