Advertisement
Lisaveta777

Triangles horisontally

Nov 1st, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #define SIZE 3
  3. #define GAP 2
  4.  
  5.  
  6. void pr_it(int,int);//
  7.  
  8. int main()
  9. {
  10.     pr_it(SIZE,GAP);
  11.  
  12.     return 0;
  13. }
  14. void pr_it(int s,int g)
  15. {
  16.     int row,col;
  17.     for(row=0;row<s;row++)
  18.     {
  19.         for(col=0;col<4*s+3*g;col++)
  20.         //for(col=0;col<79;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.  
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement