spiral like pattern program in c
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int n,i,j,boundry,num;
scanf("%d", &n);
boundry=(n*2)-1;
for(i=0;i<boundry;i++){
for(j=0;j<boundry;j++){
if(i<j) num=i; else num=j;
if(num>=boundry-i) num=boundry-i-1;
if(num>=boundry-j-1) num=boundry-j-1;
printf("%d ",n-num);
//printf("sa");
}
printf("\n");
}
return 0;
}
Comments
Post a Comment