Skip to content

Instantly share code, notes, and snippets.

@kangarie
Created October 24, 2022 04:54
Show Gist options
  • Save kangarie/daccd6a1d3fe53828eb71bc47ea08923 to your computer and use it in GitHub Desktop.
Save kangarie/daccd6a1d3fe53828eb71bc47ea08923 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(void)
{
int n,i,j,x;
printf("Enter an integer: ");
scanf("%d", &n);
for(i=1;i<=n;i++) {
for(x=1;x<=(n*(n-i)) + (n-i+1);x++) printf(" ");
for(j=1;j<=i;j++) {
for(x=1;x<=n-i;x++) printf(" ");
for(x=1;x<=i;x++) printf("%d",i);
printf(" ");
}
for(j=1;j<=i;j++) {
for(x=1;x<=i;x++) printf("%d",i);
for(x=1;x<=n-i;x++) printf(" ");
printf(" ");
}
printf("\n");
}
return 0;
}
/*
======
OUTPUT
======
$ ./piramida
Enter an integer: 6
1 1
22 22 22 22
333 333 333 333 333 333
4444 4444 4444 4444 4444 4444 4444 4444
55555 55555 55555 55555 55555 55555 55555 55555 55555 55555
666666 666666 666666 666666 666666 666666 666666 666666 666666 666666 666666 666666
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment