Advertisement
Lisaveta777

Triangles vertically

Nov 1st, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. //prints triangles vertically
  2.  
  3. #include <stdio.h>
  4. #define SIZE 3
  5. #define GAP 2
  6.  
  7. void pr_it(int,int);//
  8.  
  9. int main()
  10. {
  11.     pr_it(SIZE,GAP);
  12.  
  13.     return 0;
  14. }
  15. void pr_it(int s,int g)
  16. {
  17.     int row,col;
  18.     for(row=0;row<s;row++)
  19.     {
  20.         for(col=0;col<4*s+3*g;col++)
  21.         {
  22.                 //stars
  23.             if((  col>=0              &&col<=row)
  24.                ||(col>=s+g            &&col<2*s+g-row)
  25.                ||(col>=3*s+2*g-row-1  &&col<3*s+2*g)
  26.                ||(col>=3*s+3*g+row    &&col<=4*s+3*g+1))
  27.                 printf("*");
  28.             else
  29.                 printf("-");
  30.         }
  31.         printf("\n");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement