Advertisement
dmilicev

numbers_pattern_with_abs()_v1.c

Dec 10th, 2019
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. /*
  2.  
  3.     numbers_pattern_with_abs()_v1.c
  4.  
  5.     by Ernel Fadriquilan
  6.     https://web.facebook.com/ernel.fadriquilan
  7.  
  8. ------3
  9.  
  10. ----3 2
  11.  
  12. --3 2 1
  13.  
  14. 3 2 1 0
  15.  
  16. --3 2 1
  17.  
  18. ----3 2
  19.  
  20. ------3
  21.  
  22.  
  23. ---3
  24. --32
  25. -321
  26. 3210
  27. -321
  28. --32
  29. ---3
  30.  
  31.  
  32.     You can find all my C programs at Dragan Milicev's pastebin:
  33.  
  34.     https://pastebin.com/u/dmilicev
  35.  
  36. */
  37.  
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>     // for abs()
  41.  
  42.  
  43. int main(void)
  44. {
  45.     int i, j, k, size=3;
  46.  
  47.     printf("\n\n");
  48.  
  49.     for( i=size; i>=-size; i-- )        // print rows
  50.     {
  51.         for( j=1; j<=abs(i); j++ )      // print spaces
  52.             printf("--");
  53.  
  54.         for( k=size; k>=abs(i); k-- )   // print numbers
  55.             printf("%d ", k );
  56.  
  57.         printf("\n\n");                 // new row
  58.     }
  59.  
  60.     printf("\n\n");
  61.  
  62.     for( i=size; i>=-size; i-- )        // print rows
  63.     {
  64.         for( j=1; j<=abs(i); j++ )      // print spaces
  65.             printf("-");
  66.  
  67.         for( k=size; k>=abs(i); k-- )   // print numbers
  68.             printf("%d", k );
  69.  
  70.         printf("\n");                   // new row
  71.     }
  72.  
  73.  
  74.     printf("\n\n");
  75.  
  76.     return 0;
  77.  
  78. } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement