Created
October 24, 2022 04:54
-
-
Save kangarie/daccd6a1d3fe53828eb71bc47ea08923 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 <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