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.
for (int row=1 ;row <=n;row++ ){
hub--;
for (int col=1;col<=size;col++){
printf("%d ",n);
if (row>col && row>1 ){
if (row>=col){n--;}
}
else if (col>hub &&row >1&& size !=col ){n++;}
}
printf("\n") ;
}
int a =n;
int hub_add=n+1;
int hub_sub=n-2;
for (int row=1;row <n;row++){
a=n;
for (int col=1;col<=size;col++){
printf("%d ",a);
if(row!=n-1){
if (hub_sub>=col ){
a--;
}
if (hub_add<=col ){
a++;
}
}
}
hub_add++;
hub_sub--;
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 →
include
include
include
include
int main() { int n; scanf("%d",&n);
for (int row=1 ;row <=n;row++ ){ hub--; for (int col=1;col<=size;col++){
}
}