We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int n;
scanf("%d", &n);
// Complete the code to print the pattern.
int i,j,x;
for (i = 0; i < 2 *n - 1; i++) {
for (j = 0; j < 2 * n - 1; j++) {
x = (i < j) ? i : j;
x = (x < (2 * n - 1) - i) ? x : (2 * n - 2) - i;
x = (x < (2 * n - 1) - j) ? x : (2 * n - 2) - j;
printf("%d ", n - x);
}
printf("\n");
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Printing Pattern Using Loops
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
int main() {
}