Created
November 15, 2018 08:27
-
-
Save mfrazi/696b24f04f45d6b2174b0eb7aa19a6cd 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> | |
#define print_diamonds for(int j=0; j<n+x; j++) printf(j<n-x-1?" ":"%d", j<n-1?x-(n-j)+2:n-j+x); printf("\n") | |
int main() { | |
int n; scanf("%d", &n); | |
for(int i=0, x=0; i<n; i++, x++){print_diamonds;} | |
for(int i=1, x=n-2; i<n; i++, x--){print_diamonds;} | |
return 0; | |
} | |
/* | |
Input: | |
9 | |
Output: | |
1 | |
121 | |
12321 | |
1234321 | |
123454321 | |
12345654321 | |
1234567654321 | |
123456787654321 | |
12345678987654321 | |
123456787654321 | |
1234567654321 | |
12345654321 | |
123454321 | |
1234321 | |
12321 | |
121 | |
1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment