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

#include <stdio.h>

void BubbleSort(int x[], int dim) {
        int i, j, aux;
        for(i = 0; i < dim - 1; i++)
                for(j = i + 1; j < dim; j++)
                        if (x[i] > x[j]) {
                                aux = x[i];
                                x[i] = x[j];
                                x[j] = aux;
                        }
}

int main(){
        //printf("n=");
        int n, i, v[100];
        scanf("%d", &n);
        for(i = 0; i < n; i++)
                scanf("%d", &v[i]);
        BubbleSort(v, n);
        for(i = 0; i < n; i++)
                printf("%d ", v[i]);
        printf("\n");
        return 0;      
}


/*
 * Problema 3
 */
 
#include <stdio.h>
#include <math.h>

void unghiuri(float l[], float u[])
{                
        u[0] = acos((-l[0] * l[0] + l[1] * l[1] + l[2] * l[2]) / (2 * l[1] * l[2])) * (180 / M_PI);
        u[1] = acos(( l[0] * l[0] - l[1] * l[1] + l[2] * l[2]) / (2 * l[0] * l[2])) * (180 / M_PI);
        u[2] = acos(( l[0] * l[0] + l[1] * l[1] - l[2] * l[2]) / (2 * l[0] * l[1])) * (180 / M_PI);
}

int main()
{
        float l[3], u[3];
        scanf("%f%f%f", &l[0], &l[1], &l[2]);
        unghiuri(l, u);
        printf("%.2f %.2f %.2f\n", u[0], u[1], u[2]);
        return 0;
}                                                        
 


/*
 * Problema 4
 */
 
#include <stdio.h>

int inters(int a[], int n, int b[], int m, int c[])
{
        int i, j, k, d = 0, ok;
        for (i = 0; i < n; i++)
                for (j = 0; j < m; j++)
                        if (a[i] == b[j]) {
                                // verificam daca nu a fost deja adaugat
                                ok = 1;
                                for (k = 0; k < d; k++)
                                        if (c[k] == a[i]) {
                                                ok = 0;
                                                break;
                                        }
                                if (ok) {
                                        c[d] = a[i]; //adaugam in vector
                                        d++;            // crestem nr de elemente
                                }
                        }
        return d;
}


int main()
{
        int v1[100], v2[100], v3[100], n1, n2, n3, i;

        //printf("n1 = ");
        scanf("%d", &n1);
        //printf("Elementele v1: ");
        for (i = 0; i < n1; i++)
                scanf("%d", &v1[i]);
    
        //printf("n2 = ");
        scanf("%d", &n2);
        //printf("Elementele v2: ");
        for (i = 0; i < n2; i++)
                scanf("%d", &v2[i]);

        n3 = inters(v1, n1, v2, n2, v3); //inters returneaza dimensiunea lui v3

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

        return 0;
}
 


/*
 * Problema 5
 */
 
#include <stdio.h>
#include <string.h>

int mystrcmp(char s1[], char s2[])
{
        int n1, n2, i;
        n1 = strlen(s1);
        n2 = strlen(s2);

        for (i = 0; i < n1 && i < n2; i++) // mergem pana la min(n1, n2)
                if (s1[i] > s2[i])             // si cautam elemente diferite
                        return 1;
                else if (s1[i] < s2[i])
                        return -1;

        if (n1 > n2)
                return 1;
        if (n1 < n2)
                return -1;
        return 0;
}

int main()
{
        char s1[100], s2[100];
        scanf("%s", s1);
        scanf("%s", s2);

        printf("%d\n", mystrcmp(s1, s2));

        return 0;
}
 


/*
 * Problema 6
 */
 
#include <stdio.h>

void transform(int v[], int n, int x)
{
        int st = 0, dr = n - 1, aux;
        while (st < dr) {
                while (v[st] < x && st < n) // cat timp respecta ordinea avansam la stanga
                        st++;
                while (x <= v[dr] && dr > 0) // si la dreapta
                        dr--;
                if (st < dr) {  // am gasit o pereche inversata
                        aux = v[st];
                        v[st] = v[dr];
                        v[dr] = aux;
                }
        }
}

int main()
{
        int v[100], n, x, i;

        //printf("n = ");
        scanf("%d", &n);                  
        //printf("x = ");
        scanf("%d", &x);
        //printf("Introduceti elementele: ");
        for (i = 0; i < n; i++)
                scanf("%d", &v[i]);

        transform(v, n, x);

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

        printf("\n");

        return 0;
}
 


/*
 * Problema 7
 */
 
#include <stdio.h>

void spirala(int A[][100], int m, int n, int V[])
{
        int pi, pj, i, j, dir = 0, newi, newj, nr = 0,
                limup = 0, limdown = m - 1, limleft = 0, limright = n - 1;
        int px[4] = {0, 1, 0, -1}, py[4] = {1, 0, -1, 0};
        i = 0; j = 0; // pozitia initiala

        V[0] = A[0][0]; nr++;
        while (nr < m * n) {
                newi = i + px[dir];
                newj = j + py[dir];
                if (!(limup <= newi && newi <= limdown && limleft <= newj && newj <= limright)) {
                        switch (dir) {
                case 0: if (limup < limdown) limup++; break;
                                case 2: if (limdown > limup) limdown--; break;
                                case 1: if (limright > limleft) limright--; break;
                                case 3: if (limleft < limright) limleft++; break;
                        }
                        dir = (dir + 1) % 4;
                }
                i = i + px[dir];    
                j = j + py[dir];
                V[nr] = A[i][j];
                nr++;
        }
}

void afisare(int V[], int dim)
{
        int i;
        for (i = 0; i < dim; i++)
                printf("%d ", V[i]);
        printf("\n");
}

int main()
{
        int A[100][100], m, n, V[10000], i, j;
        scanf("%d%d", &m, &n);
        for (i = 0; i < m; i++) {
                //printf("Linia %d : ", i);
                for (j = 0; j < n; j++)
                        scanf("%d", &A[i][j]);
        }
        spirala(A, m, n, V);
        afisare(V, m * n);
        return 0;
}