Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- char *rush_top_bottom(char *str, int x, char right, char left)
- {
- char *string;
- int j;
- j = 0;
- *str = left;
- str++;
- while (j < x - 2)
- {
- *str = '-';
- str++;
- j++;
- }
- if (x >= 2)
- {
- *str = right;
- str++;
- }
- *str = '\n';
- str++;
- return (str);
- }
- char *rush00(int x, int y)
- {
- char *tmp;
- char *str;
- int i;
- int j;
- str = (char*)malloc(sizeof(char) * (x + 1) * y);
- tmp = str;
- j = 0;
- if (x <= 0 || y <= 0)
- return (0);
- str = rush_top_bottom(str, x, 'o', 'o');
- while (j < y - 2)
- {
- i = 0;
- *str = '|';
- str++;
- while (i < x - 2)
- {
- *str = ' ';
- str++;
- i++;
- }
- if (x >= 2)
- {
- *str = '|';
- str++;
- }
- *str = '\n';
- str++;
- j++;
- }
- if (y >= 2)
- str = rush_top_bottom(str, x, 'o', 'o');
- return (tmp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement