Pentru fisierele sursa cu rezolvarile, verificati arhiva.
/*
 * Problema 2
 *
 */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>


char *my_strdup(char *s)
{
        char *p = (char *) malloc(strlen(s) + 1);
        strcpy(p, s);
        return p;
}

int main()
{
        char buf[512];
        char *p;
        scanf("%s", buf);
        p = my_strdup(buf);
        printf("%s", p);
        return 0;
}


/*
 * Problema 3
 *
 */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

char *my_replace(char *s, char *s1, char *s2)
{
        /*in vectorul auxiliar se aloca memorie(din sirul total se scaote sirul care trebuie inlocuit
          si se aduaga dimensiunea sirului cu care este inlocuit */
        char *aux = (char *) malloc((sizeof(s) - sizeof(s1)) + sizeof(s2) + 1);
        int i = strstr(s, s1) - s, j = strlen(s1);
        strncpy(aux, s, i);
        strcat(aux, s2);
        strncat(aux, (s + i + j), (strlen(s) - i - j));
        return aux;
}


int main()
{
        char *s, *s1, *s2;
        s = (char*)malloc(10);
        s1 = (char*)malloc(10);
        s2 = (char*)malloc(10);
        char *aux;
        scanf("%s%s%s", s, s1, s2);
        aux = my_replace(s, s1, s2);
        printf("%s\n", aux);
        return 0;
}


/*
 * Problema 4
 *
 */

#include <stdio.h>
#include <stdlib.h>

int main(){
        int i, *v, n, cap, nr;

        n = 0; //initial sunt 0 elemente in vector
        cap = 5; //capacitatea initiala
        v = (int*) malloc(cap * sizeof(int));

        scanf("%d", &nr);
        while (nr != 0 ) {
                if (cap == n) {
                        cap *= 2;
                        v = realloc(v, cap * sizeof(int));
                        }
                v[n++] = nr;            
                scanf("%d", &nr);
                }

        for(i = 0; i < n; i++)
                printf("%d ", v[i]);
        printf("\n");

        return 0;
}


/*
 * Problema 5
 *
 */

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main()
{
        int n, i;
        char (*cuvinte_u)[20] = NULL, (*cuvinte)[20]; // un pointer la un sir de 20 caractere
        int *aparitii;
        scanf("%d\n", &n);
        cuvinte = (char (*)[20]) malloc(n * sizeof(char[20]));

        i = 0;
        while (i < n) {
                scanf("%s", cuvinte[i]);
                i++;
        }

        int dim = 4, unice = 0, k;
        cuvinte_u = (char (*)[20]) malloc(dim * sizeof(char[20]));
        aparitii = (int *) malloc(dim * sizeof(int));

        for (i = 0; i < n; i++) {
                int found = 0;          // variabila care va indica daca am gasit cuvantul in vectorul de aparitii unice

                for (k = 0; k < unice; k++) {
                        if (strcmp(cuvinte_u[k], cuvinte[i]) == 0) {
                                aparitii[k]++;
                                found = 1;
                        }
                }

                if (found != 1) {       //in cazul in care vucantul nu a fost gasit in vectorul de valori unice
                        if (unice >= dim) {     //in cazul in care dimensiunea vectorului unic nu a ajuns la limita
                                dim *= 2;
                                aparitii = (int *) realloc(aparitii, dim * sizeof(int));
                                cuvinte_u = (char (*)[20]) realloc(cuvinte_u, dim * sizeof(char[20]));
                        }

                        strcpy(cuvinte_u[unice], cuvinte[i]);
                        aparitii[unice] = 1;
                        unice++;
                }
        }
        for (i = 0; i < unice; i++)     { //afisarea rezultatelor
                printf("%s %d\n", cuvinte_u[i], aparitii[i]);
        }
        //dealocare de memorie
        free(aparitii);
        free(cuvinte_u);
        free(cuvinte);
        return 0;
}


/*
 * Problema 6
 *
 */

#include <stdio.h>
#include <stdlib.h>

int main(){
        int n1, *vim1;
        int n0, *vi;
        int i, j, k, n, *p;

        vim1 = (int*) malloc(n1 * sizeof(int));
        vi = (int*) malloc(n * sizeof(int));

        vim1[0] = 1; n1 = 1;
        vi[0] = 1; vi[1] = 1; n0 = 2;
        
        scanf("%d%d", &n, &k);

        i = 1;

        while (i < n) {
                p = vim1; vim1 = vi; vi = p;
                n1 = n0;
                
                n0++;
                vi = (int*)realloc(vi, n0 * sizeof(int));
                vi[0] = 1;
                for(j = 1; j < n0; j++)
                        vi[j] = vim1[j] + vim1[j - 1];
                vi[n0 - 1] = 1;

                i++;
                }

        printf("%d\n", vi[k]);

        return 0;
}