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.
#include<stdio.h>intmain(){intn;scanf("%d",&n);intsize=2*n-1;// Print the patternfor(inti=0;i<size;i++){for(intj=0;j<size;j++){// Determine the value to printintmin_distance=i<size-i-1?i:size-i-1;min_distance=j<size-j-1?min_distance<j?min_distance:j:min_distance<size-j-1?min_distance:size-j-1;printf("%d ",n-min_distance);}printf("\n");}}
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 →