Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* required is a function star (int n) that outputs n lines following this pattern:
- *
- ***
- *****
- *******
- .. etc, no loops or secondary functions allowed
- */
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- void star(int rows)
- {
- if (rows == 0) return;
- static int b =1;
- static char *stars;
- if (b)
- {
- b=0;
- stars = malloc(rows*rows+1);
- strcpy(stars, "*");
- }
- star(rows-1);
- printf("%s\n", stars);
- stars = strcat(stars, "**");
- }
- int main (void)
- {
- star(5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement