Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created January 3, 2014 07:31
Show Gist options
  • Save marcoscastro/8234266 to your computer and use it in GitHub Desktop.
Save marcoscastro/8234266 to your computer and use it in GitHub Desktop.
Implementação do triângulo de Floyd em C
#include <stdio.h>
// imprime triângulo de floyd até linha N
void mostrar_triangulo(int N)
{
if(N < 1)
return;
int i = 0, qte = 1, num = 1;
while(i < N)
{
int j;
for(j = 0; j < qte; j++)
{
printf("%d\t", num);
num++;
}
printf("\n");
qte++;
i++;
}
}
int main(int argc, char *argv[])
{
mostrar_triangulo(10);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment