Advertisement
Voldemord

c GOTO cristmasTree

Feb 27th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. void drawTree(int h);
  3.  
  4. int main()
  5. {
  6.     int h;
  7.     char c;
  8.     int hi;
  9.     int si;
  10.     int pi;
  11.  
  12.     repeat:
  13.  
  14.     printf("Podaj wysokosc: ");
  15.     scanf("%d", &h);
  16.  
  17.  
  18.  
  19.     if(h%2 == 0)
  20.     {
  21.         c = '*';
  22.     } else {
  23.         c = '#';
  24.     }
  25.  
  26.     hi = 1;
  27.     drawTree:
  28.  
  29.         si = 0;
  30.         pi = 0;
  31.  
  32.         drawSpace:
  33.         if(h>hi+si)
  34.         {
  35.             printf(" ");
  36.             si++;
  37.             goto drawSpace;
  38.         }
  39.  
  40.         drawPoint:
  41.         if(h>pi-hi*2+h+1)
  42.         {
  43.             printf("%c",c);
  44.             pi++;
  45.             goto drawPoint;
  46.         }
  47.  
  48.     if(hi < h)
  49.     {
  50.  
  51.         hi++;
  52.         printf("\n");
  53.         goto drawTree;
  54.     }
  55.     printf("\n");
  56.     if(h >=7)
  57.     {
  58.         goto stop;
  59.     }
  60.     goto repeat;
  61.  
  62.     stop:
  63.  
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement