Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main (void)
- {
- char tree[9][12];
- memset(tree, ' ', 9*11 - 1);
- int r, c;
- for (r = 0; r < 6; tree[r][11] = '\n', r++)
- memset(&tree[r][5-r], '*', 2*r + 1);
- for (r = 6; r < 9; tree[r][11] = '\n', r++)
- memset(&tree[r][(11-7) / 2], '*', 7);
- tree[8][11] = '\0';
- printf("Enter row number: ");
- scanf("%d", &r);
- printf("Enter column number: ");
- scanf("%d", &c);
- char ch;
- printf("Enter character: ");
- scanf(" %c", &ch);
- r--, c--;
- if (tree[r][c] == '*')
- tree[r][c] = ch;
- else
- printf("Error: (%d,%d) is out of bounds\n", r, c);
- printf((char *)tree);
- return 0;
- }
Add Comment
Please, Sign In to add comment