void getNumberPattern(int n) { // Write your code here. for(int i=0;i<2*n-1;i++){ for(int j=0;j<2*n-1;j++){ int top=i; int left=j; int bottom=(2*n-2)-i; int right=(2*n-2)-j; cout<<n-min(min(top,left),min(right,bottom)); } cout<<"\n"; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter