#include<stdio.h> void main() { int i,n,j; printf("\n Enter Value of N: "); scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n-i;j++) printf(" "); for(j=i;j>=0;j--) printf(" %d",j); for(j=1;j<=i;j++) printf(" %d",j); printf("\n"); } }
/*
Enter Value of N: 9
0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5
6 5 4 3 2 1 0 1 2 3 4 5 6
7 6 5 4 3 2 1 0 1 2 3 4 5 6 7
8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8
*/
No comments:
Post a Comment