2021-09-29 23:10:38 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "character.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
char* type = input();
|
2023-08-10 11:13:06 +02:00
|
|
|
unsigned long height;
|
|
|
|
scanf("%lu", &height);
|
2021-09-29 23:10:38 +02:00
|
|
|
|
2023-08-10 11:13:06 +02:00
|
|
|
unsigned long step = strcmp(type, "normal") == 0 ? 1 : height;
|
2021-09-29 23:10:38 +02:00
|
|
|
while ((strcmp(type, "normal") == 0 && step <= height) || (strcmp(type, "reverse") == 0 && step != 0)) {
|
2021-10-13 21:43:45 +02:00
|
|
|
size_t numberOfStars = (step * 2) - 1;
|
|
|
|
size_t totalNumberOfLocations = (height * 2) - 1;
|
|
|
|
size_t totalNumberOfSpaces = totalNumberOfLocations - numberOfStars;
|
|
|
|
size_t numberOfSpacesOnEachSide = totalNumberOfSpaces / 2;
|
2021-09-29 23:10:38 +02:00
|
|
|
character_print(" ", numberOfSpacesOnEachSide);
|
|
|
|
character_print("*", numberOfStars);
|
|
|
|
character_print(" ", numberOfSpacesOnEachSide);
|
|
|
|
printf("\n");
|
|
|
|
step = strcmp(type, "normal") == 0 ? step + 1 : step - 1;
|
|
|
|
}
|
|
|
|
|
2023-08-10 11:13:06 +02:00
|
|
|
free(type);
|
2021-09-29 23:10:38 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|