Sunday 18 September 2016

Number pattern : X

1     1
2 2
3 3
4
3 3
2 2
1 1

CODE

int main()
{
int i,j,k=1;
int m[7][7]={0};
for(i=1;i<=7;i++)
{
for(j=1;j<=7;j++)
if(j==i || 8-i==j)
m[i-1][j-1]=k;
if(i<4) k++;
else --k;

}
for(i=0;i<7;i++)
{
for(j=0;j<7;j++)
{
if(m[i][j]==0)
printf(" ");
else
printf("%d",m[i][j]);
}
printf("\n");
}
return 0;
}

No comments:

Post a Comment

Featured post

The Thrill of Programming: Exploring the Satisfaction Behind the Code

Different individuals find satisfaction in programming for various reasons. Here are some common factors that tend to bring satisfaction to ...