Skip to content

Instantly share code, notes, and snippets.

@Silva97
Created March 20, 2020 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Silva97/54f72ab5097c95d0baf87809b971c182 to your computer and use it in GitHub Desktop.
Save Silva97/54f72ab5097c95d0baf87809b971c182 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
void triangle(int, int);
int main(int argc, char **argv)
{
triangle(atoi(argv[1]), 0); // 17
return 0;
}
void triangle(int times, int indentation)
{
if (times <= 0)
return;
if (indentation > 0)
printf("%*c", indentation, ' ');
for (int i = 0; i < times; i++)
putchar('*');
putchar('\n');
triangle(times-2, indentation+1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment