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.
intmain(){intn;scanf("%d",&n);intarr[2*n-1][2*n-1];// initialize all the array with n// then replace everything except for the outer ring with n - 1 ...// until reaching 1for(intj=0;j<n;j++){for(inti=j;i<=2*n-2-j;i++){for(intk=j;k<=2*n-2-j;k++){arr[i][k]=n-j;}}}// print the array for(inti=0;i<2*n-1;i++){for(intj=0;j<2*n-1;j++){printf("%d ",arr[i][j]);}printf("\n");}return0;}
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 →