a3f

https://www.facebook.com/photo.php?fbid=636756883089269&set=

a3f
Mar 25th, 2014
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main (void)
  4. {
  5.     char tree[9][12];
  6.     memset(tree, ' ', 9*11 - 1);
  7.     int r, c;
  8.     for (r = 0; r < 6; tree[r][11] = '\n', r++)
  9.         memset(&tree[r][5-r], '*', 2*r + 1);
  10.     for (r = 6; r < 9; tree[r][11] = '\n', r++)
  11.         memset(&tree[r][(11-7) / 2], '*', 7);
  12.     tree[8][11] = '\0';
  13.  
  14.     printf("Enter row number: ");
  15.     scanf("%d", &r);
  16.     printf("Enter column number: ");
  17.     scanf("%d", &c);
  18.     char ch;
  19.     printf("Enter character: ");
  20.     scanf(" %c", &ch);
  21.  
  22.     r--, c--;
  23.     if (tree[r][c] == '*')
  24.         tree[r][c] = ch;
  25.     else
  26.         printf("Error: (%d,%d) is out of bounds\n", r, c);
  27.    
  28.     printf((char *)tree);
  29.  
  30.     return 0;
  31. }
Add Comment
Please, Sign In to add comment