Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- numbers_pattern_with_abs()_v1.c
- by Ernel Fadriquilan
- https://web.facebook.com/ernel.fadriquilan
- ------3
- ----3 2
- --3 2 1
- 3 2 1 0
- --3 2 1
- ----3 2
- ------3
- ---3
- --32
- -321
- 3210
- -321
- --32
- ---3
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- #include <stdlib.h> // for abs()
- int main(void)
- {
- int i, j, k, size=3;
- printf("\n\n");
- for( i=size; i>=-size; i-- ) // print rows
- {
- for( j=1; j<=abs(i); j++ ) // print spaces
- printf("--");
- for( k=size; k>=abs(i); k-- ) // print numbers
- printf("%d ", k );
- printf("\n\n"); // new row
- }
- printf("\n\n");
- for( i=size; i>=-size; i-- ) // print rows
- {
- for( j=1; j<=abs(i); j++ ) // print spaces
- printf("-");
- for( k=size; k>=abs(i); k-- ) // print numbers
- printf("%d", k );
- printf("\n"); // new row
- }
- printf("\n\n");
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement