Created
October 17, 2024 09:26
-
-
Save marsgpl/a42f555323aea20317c28ab0ab0ef656 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
#define STARS "****************************************************" | |
void print_pyramid(int levels_n) { | |
int max_w = levels_n + levels_n - 1; | |
for (int level = 1; level <= levels_n; ++level) { | |
int stars_n = level + level - 1; | |
int pad = (max_w - stars_n) / 2; | |
printf("%*s%.*s%*s\n", pad, "", stars_n, STARS, pad, ""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment