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

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

void strtolower(char *s)
{
        int i, n;
        for (i = 0, n = strlen(s); i < n; i++)
                s[i] = tolower(s[i]);
}

int main(int argc, char *argv[])
{
        FILE *f = fopen(argv[argc - 2], "r");
        char buffer[1000];
        int o_i = 0, o_n = 0, o_c = 0;
        int nr = 0, i, ct = 0;
        for (i = 1; i < argc - 2; i++) { // parcurgem lista de optiuni
                switch (argv[i][1]) {
                        case 'i' : o_i = 1; break;
                        case 'n' : o_n = 1; break;
                        case 'c' : o_c = 1; break;
                }
        }
        if (o_i)
                strtolower(argv[argc - 1]);
        while (fgets(buffer, 1000, f) != NULL) {
                nr++;
                if (o_i)
                        strtolower(buffer);
                if (strstr(buffer, argv[argc - 1])) {
                        ct++;
                        if (o_n)
                                printf("%d : ", nr);
                        printf("%s", buffer);
                }
        }
        if (o_c)
                printf("%d lines\n", ct);
        fclose(f);
        return 0;
}


/*
 * Problema 3
 *
 */

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

#define MAXN 1000

typedef struct {
        char nume[100];
        char prenume[100];
        float n_a, n_e, n_f;
} STUDENT;

int main(int argc, char *argv[])
{
        char buffer[1000];
        int i, n = 0, np = 0, nr_elevi;
        float max;
        STUDENT st[MAXN];
        FILE *f = fopen(argv[1], "r");
        fscanf(f, "%d", &nr_elevi);
        //while (fscanf(f, "%s%s%f%f", st[n].nume, st[n].prenume, &st[n].n_a, &st[n].n_e) == 4) {
        for(n = 0; n < nr_elevi; n++) {
                fscanf(f, "%s%s%f%f", st[n].nume, st[n].prenume, &st[n].n_a, &st[n].n_e);
                // calcul si afisare nota finala
                st[n].n_f = (st[n].n_a + 2 * st[n].n_e) / 3;
                printf("Nota finala %s %s: %.2f ", st[n].nume, st[n].prenume, st[n].n_f);
                // verificare promovat
                if (st[n].n_f >= 5 && st[n].n_a >= 5 && st[n].n_e >= 5) {
                        np++;
                        printf("promovat\n");
                }
                else 
                        printf("nepromovat\n");
                // verificare nota maxima
                if (st[n].n_f > max)
                        max = st[n].n_f;
                //n++;
        }
        printf("%d studenti promovati.\n%.2f%%(procent de promovabilitate)\n", np, np * 100.0 / n);
        printf("Nota maxima = %.2f. Studenti care au obtinut nota maxima:\n", max);
        for (i = 0; i < n; i++)
                if (st[i].n_f == max)
                        printf("%s %s\n", st[i].nume, st[i].prenume);
        fclose(f);
        return 0;
}


/*
 * Problema 4
 *
 */

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

int main(int argc, char *argv[])
{
        FILE *cod, *in, *out;
        char c[128]; // pentru fiecare caracter ii vom retine codul
        char chi, cho, buffer[1000];
        int i, n;

        cod = fopen(argv[1], "r");
        in = fopen(argv[2], "r");
        out = fopen(argv[3], "w");

        for (i = 0; i < 128; i++)
                c[i] = i; // daca nu exista codificare, caracterul ramane la fel
        while (fgets(buffer, 1000, cod) != NULL) {
                if (sscanf(buffer, "%c %c", &chi, &cho)==2)
                        c[chi] = cho;
        }

        while (fgets(buffer, 1000, in) != NULL) {
                for (i = 0, n = strlen(buffer); i < n; i++)
                        fprintf(out, "%c", c[buffer[i]]);
        }

        fclose(cod);
        fclose(in);
        fclose(out);
        return 0;
}