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.
Printing Pattern Using Loops
Printing Pattern Using Loops
Sort by
recency
|
1025 Discussions
|
Please Login in order to post a comment
include
include
include
include
int main() { int n; scanf("%d", &n);
}
include
int main() { int n; scanf("%d", &n); for(int i = -n + 1;i <= 0;i++){ for(int j = 0;j < i + n - 1;j++){ printf("%d ", n - j); } for(int j = n + i;j <= n - i;j++){ printf("%d ", -i + 1); } for(int j = i + n - 2;j >= 0;j--){ printf("%d ", n - j); } printf("\n"); } for(int i = 1;i < n;i++){ for(int j = 0;j <= n - 1 - i;j++){ printf("%d ", n - j); } for(int j = n - i;j < n + i;j++){ printf("%d ", i + 1); } for(int j = n - 1 - i - 1;j >= 0;j--){ printf("%d ", n - j); } printf("\n"); } return 0; }
`