You are viewing a single comment's thread. Return to all comments →
#include<stdio.h> int main(){ int n; scanf("%d",&n); int l=((n-1)*2)+1; int matrix[l][l]; int x=1,i,y=2; int mid=n-1; for(x;x<n;x++){ i=0; for(i=0;i<l;i++){ matrix[mid+x][i]=y; matrix[mid-x][i]=y; } i=0; for(i=0;i<l;i++){ matrix[i][mid+x]=y; matrix[i][mid-x]=y; } y++; } matrix [mid][mid]=1; int j=0; i=0; for (i = 0; i < l; i++) { for ( j = 0; j < l; j++) { printf("%d ", matrix[i][j]); } printf("\n"); j=0; } return 0; }
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 →