Last active
November 3, 2023 22:18
-
-
Save gouravkhunger/2e04ef07c8da2b8dfbc709dcf1fafdb3 to your computer and use it in GitHub Desktop.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (fool) ? maybe : maybeNot
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
/* | |
This program prints a sexy pyramid with the following pattern sequence: | |
input: 15 | |
output: | |
1 | |
232 | |
34543 | |
4567654 | |
567898765 | |
67890109876 | |
7890123210987 | |
890123454321098 | |
90123456765432109 | |
0123456789876543210 | |
123456789010987654321 | |
23456789012321098765432 | |
3456789012345432109876543 | |
456789012345676543210987654 | |
56789012345678987654321098765 | |
Guys, don't copy the code, use for reference only! ;) | |
@author Gourav Khunger (github/gouravkhunger), Vardhaman Kalloli (github/cyai); | |
@version 1.0 | |
@since 3:34AM 04-11-2023 | |
*/ | |
#include <stdio.h> | |
int main(void) { | |
int n; | |
printf("Enter the height of your sexy pyramid: "); | |
scanf("%d", &n); | |
int c = 0; | |
for(int i = 0; i < n; i++) { | |
for (int j = 0; j < (n - i - 1); j++) putchar(' '); | |
c = i == 0 ? 1 : ((i + 1) % 10); | |
for (int j = 0; j <= i; j++, c++, c = c > 9 ? 0 : c) | |
printf("%d", c); | |
c -= 2; | |
c = c < 0 ? 8 : c; | |
for (int j = 0; j < i; j++, c--, c = c < 0 ? 9 : c) | |
printf("%d", c); | |
putchar('\n'); | |
} | |
return 0; | |
} |
cyai
commented
Nov 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment