1 2 3 4 5 5 4 3 2 1
1 2 3 4 4 3 2 1
1 2 3 3 2 1
1 2 2 1
1 1
1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1
1 2 3 4 5 5 4 3 2 1
=======================================================
/*Serial No.41 [swami12.cpp]*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l=0,m=1,n;
clrscr();
printf("Enter the last number==>");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1-i;j++)
printf("%d",j);
for(k=1;k<=l;k++)
printf(" ");
for(j=n+1-i;j>=1;j--)
printf("%d",j);
l=l+2;
printf("\n");
}
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
printf("%d",j);
for(k=1;k<=2*n-1-m;k++)
printf(" ");
for(j=i;j>=1;j--)
printf("%d",j);
m=m+2;
printf("\n");
}
getch();
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...