Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- number pattern 2 v1.c
- Program by Debottam Das
- https://www.facebook.com/debottam.das.121
- Enter a number of rows (1 to 9) 9
- 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
- 1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1
- 1 2 3 4 5 6 7 7 6 5 4 3 2 1
- 1 2 3 4 5 6 6 5 4 3 2 1
- 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
- */
- #include<stdio.h>
- void number_pattern_2(int n)
- {
- int i, j, k, start;
- k = n;
- for(i=0; i<n; i++)
- {
- start = 0;
- for(j=0; j<2*n-1; j++)
- {
- if(j < n)
- start++;
- else
- start--;
- if(j<k || j>2*n-k-2)
- printf("%d ",start);
- else
- printf(" ");
- }
- k--;
- printf("\n");
- }
- }
- int main(void)
- {
- int number_of_rows;
- printf("\n Enter a number of rows (1 to 9) : ");
- scanf("%d",&number_of_rows);
- printf("\n");
- number_pattern_2(number_of_rows);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement