SHARE
TWEET

Untitled

a guest Mar 21st, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.   void upper(int width) {
  4.     int i, j, k = 0;
  5.     for (i = 1; i <= width; i++) {
  6.       for (j = 1; j <= width - i; j++) printf(" ");
  7.       for (k = 0; k < 2 * i - 1; k++) printf("*");
  8.       printf("\n");
  9.     }
  10.   }
  11.  
  12. /* while (k != (2 * i - 1)) {
  13.    printf("*");
  14.    k++;
  15.  }
  16.  k = 0;
  17.  printf("\n");*/
  18.  
  19. void lower(int width) {
  20.   int i, j;
  21.   for (i = 1; i <= 4; i++) {
  22.     for (j = 1; j <= 2 * width; j++) {
  23.       if (j != width) printf(" ");
  24.       else printf("*");
  25.     }
  26.     printf("\n");
  27.   }
  28.  
  29. }
  30.  
  31. main() {
  32.   int width, height, i;
  33.   printf("Please enter tree height: ");
  34.   scanf("%d", & height);
  35.  
  36.   printf("\nPlease enter tree witdth: ");
  37.   scanf("%d", & width);
  38.  
  39.   for (i = 1; i <= height; i++) {
  40.     upper(width);
  41.   }
  42.   lower(width);
  43. }
RAW Paste Data
Top