Created
October 6, 2017 20:37
-
-
Save pschichtel/0d429eaff2d69c3a88ae6bfda82bf130 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include<stdlib.h> | |
#include<stdio.h> | |
#include<math.h> | |
#define MIN_STEM_HEIGHT 1 | |
#define MIN_STEM_WIDTH 1 | |
int main(int argc, char** argv) { | |
int crownHeight = (argc < 2) ? 10 : atoi(argv[1]); | |
int i, j; | |
for (i = 0; i < crownHeight; ++i) | |
{ | |
for (j = 0; j < (crownHeight - i - 1); ++j) | |
{ | |
printf(" "); | |
} | |
printf("o"); | |
for (j = 0; j < i; ++j) | |
{ | |
printf("oo"); | |
} | |
printf("\n"); | |
} | |
int stemHeight = (int)(crownHeight * 0.20 + 0.5); | |
if (stemHeight < MIN_STEM_HEIGHT) | |
{ | |
stemHeight = MIN_STEM_HEIGHT; | |
} | |
int stemWidth = (int)((crownHeight * 2 - 1) * 0.10 + 0.5); | |
if (stemWidth < MIN_STEM_WIDTH) | |
{ | |
stemWidth = MIN_STEM_WIDTH; | |
} | |
for (i = 0; i < stemHeight; ++i) | |
{ | |
for (j = 0; j < (crownHeight - stemWidth - 1); ++j) | |
{ | |
printf(" "); | |
} | |
printf("#"); | |
for (j = 0; j < stemWidth; ++j) | |
{ | |
printf("##"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment