Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void fibs(int n, char s1[], char s2[], int i) {
- if (n == 1) {
- puts(s1);
- return;
- }
- if (n == 2) {
- puts(s2);
- return;
- }
- int len1 = strlen(s1);
- int len2 = strlen(s2);
- char *s3 = malloc(sizeof(char) * (len1 + len2 + 1));
- s3[0] = 0;
- strcat(s3, s1);
- strcat(s3, s2);
- if (n == i) {
- puts(s3);
- free(s3);
- return;
- }
- fibs(n, s2, s3, i + 1);
- free(s3);
- }
- int main(void) {
- int n = 4;
- char s1[] = "ads", s2[] = "123";
- fibs(n, s1, s2, 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement