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
|
1019 Discussions
|
Please Login in order to post a comment
simple and easy answer
takes the minimum out of i,j,size-i-1 and size-j-1, where size is 2n-1
core component of this code: for(int x=0;x=n;x--) { for(int y=2*(n-1)-z;y>=z;y--){ a[x][y]=n-z; a[y][x]=n-z; } z++;}
include
void main( ) { int n; printf("Give input"); scanf("%i",&n); for(int i=1; i <= 2*n-1;i++) { int k=1; for(int j=1;j <= 2*n-1; j++) { for(int m=1;mi) k --; if(j>=2*n-i+1) k --; break; } printf("%i ",n-k+1); } printf("\n"); } }
include
include
include
include
int main() {
}
include
include
include
include
int main() {
}