I. 1.

    b. n = n / 10 % 100

    I. 2.
    a)

    rezultat = 224, iteratii = 7


    b)

    b minim = 11, b maxim = 32


    c)

                                        
                                            CITESTE a, b
                                            s <- a
                                            r <- 0
                                            iteratii <- 0
                                            CAT TIMP b > 1 EXECUTA
                                                iteratii <- iteratii + 1
                                                cnt <- 0
                                                cp <- b
                                                CAT TIMP b > 0 EXECUTA
                                                    b <- b - 2
                                                    cnt <- cnt + 1
                                                DACA b = 0 ATUNCI
                                                    b <- cnt
                                                    s <- s + s
                                                ALTFEL
                                                    r <- r + s
                                                    b <- cp - 1
                                            rezultat <- s + r
                                        
                                    


    d).

                                    
                                        #include <iostream>
                                        using namespace std;
    
                                        int a, b, s, r, iteratii, rezultat;
    
                                        int main(){
                                            cin>>a>>b;
                                            s = a;
                                            r = 0;
                                            iteratii = 0;
                                            while(b > 1){
                                                iteratii ++;
                                                if( b % 2 == 0){
                                                    s += 2;
                                                    b /= 2;
                                                }
                                                else{
                                                    r += s;
                                                    b -= 1;
                                                }
                                            }
                                            rezultat = s + r;
                                            return 0;
                                        }
                                    
                                  

    II. 1.

    a.0

    II. 2.

    b.6

    II. 3.

                                        
                                            int a = out(q1);
                                            int b = out(q1);
                                            int c = out(q1);
                                            add(q2, c);
                                            add(q2, b);
                                            add(q2, a);
                                        
                                    

    II. 4.

                                         
                                            #include < iostream >
                                            #include <cstring >
                                            using namespace std;
                                            
                                            char s[105], S[105][105], P[105][105], C[105][105];
                                            int szS, szP, szC;
                                            
                                            int main(){
                                                while(cin>>s){
                                                    char cv[105];
                                                    int it = 0, sz = 0;
                                                    while(s[it] != '#'){
                                                        cv[sz++] = s[it++];
                                                    }
                                                    it++;
                                                    cv[sz] = '\0';
                                                    if(s[it] == 'S')
                                                        strcpy(S[szS++], cv);
                                                    if(s[it] == 'P')
                                                        strcpy(P[szP++], cv);
                                                    if(s[it] == 'C')
                                                        strcpy(C[szC++], cv);
                                                }
                                            
                                                for(int i = 0; i < szS; i++)
                                                    for(int j = 0; j < szP; j++)
                                                        for(int k = 0; k < szC; k++)
                                                           cout<< S[i]<<" "<<P[j]<<" "<<C[k]<<','<<" ";
                                                return 0;
                                            }   
                                        
                                    

    II. 5.

                                         
                                            #include <iostream>
                                            using namespace std;
    
                                            struct P{
                                                int lin, col;
                                            }q[105 * 105];
    
                                            int n, A[105][105], cnt;
                                            int di[] = {-1, 0, 1, 0};
                                            int dj[] = {0, 1, 0, -1};
    
                                            int main(){
                                                cin>>n;
                                                for(int i = 0; i < n; i++)
                                                    for(int j = 0; j < n; j++)
                                                        cin>>A[i][j];
    
                                                for(int i = 0; i < n; i++)
                                                    for(int j = 0; j < n; j++)
                                                        if(A[i][j] == 1){
                                                            cnt++;
                                                            int st = 1, dr = 1;
                                                            q[st].lin = i;
                                                            q[st].col = j;
    
                                                            while(st <= dr){
                                                                int x = q[st].lin, y = q[st].col;
                                                                st++;
                                                                A[x][y] = -cnt;
                                                                for(int k = 0; k < 4; k++){
                                                                    int iv = x + di[k], jv = y + dj[k];
                                                                    if(iv >= 0 && iv < n && jv >= 0 && jv < n && A[iv][jv] == 1){
                                                                        q[++dr].lin = iv;
                                                                        q[dr].col = jv;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                cout<<cnt<<"\n";
                                                for(int c = 1; c <= cnt; c++){
                                                    cout<<'G'<<c<<"={";
                                                    for(int i = 0; i < n; i++)
                                                        for(int j = 0; j < n; j++)
                                                            if(A[i][j] == -c){
                                                                cout<<'('<<i<<','<<j<<')'<<" ";
                                                            }
                                                    cout<<'}'<<" ";
                                                }
    
    
                                            }
                                         
                                    

    III. 1.

    c. 48

    III. 2.

    F(1234) = 0

    III. 3.
    a)

    O solutie pentru problema descrisa se bazeaza pe metoda backtracking.
    Putem amplasa in vectorul solutie toate generarile pentru linie si coloana.
    Pentru orice k din [i - 1, 0] verificam:
    1) daca s[i] == s[k] (in acest caz coloanele sunt egale)
    2) daca (i - s[i] == k - s[k]) || (s[i] + i == s[k] + k) ( in acest caz reginele se afla pe aceeasi diagonala)
    Daca 1 si 2 sunt false inseamna ca regina de pe linia i este plasata corect si putem merge la linia i + 1.

    b)

                                        
                                            void check(int n, int k, int s[105], int a[105][105]){
                                                for(int i = 0; i < n; i++)
                                                    for(int j = 0; j < n; j++)
                                                        a[i][j] = 0;
                                                for(int x = 0; x < n; x++)
                                                    if(s[x] != -1)
                                                        a[x][s[x]] = 1;
                                            
                                                for(int i = 0; i < n; i++)
                                                    for(int j = 0; j < n; j++)
                                                        if(a[i][j] == 0){
                                                            int p = 0;
                                                            for(int x = 0; x < k; x++)
                                                                if(x == i || s[x] == j || (x - s[x] == i - j) || (x + s[x] == i + j))
                                                                    p++;
                                                            a[i][j] = -p;
                                                        }
                                            }
                                        
                                    

    c)

                                        
                                            #include <iostream>
                                            using namespace std;
    
                                            void back(int k, int s[105], int n, bool &g){
                                                for(int i = 0; i < n && g == false; i++){
                                                    int a[105][105];
                                                
                                                    check(n,k,s,a);
                                                    if(a[k][i] == 0){
                                                        s[k] = i;
                                                        if(k == (n - 1) && g == false){
                                                            g = true;
                                                            a[k][i] = 1;
                                                            for(int i = 0; i < n; i++, cout<<"\n")
                                                                for(int j = 0; j < n; j++)
                                                                    if(a[i][j] == 1)
                                                                        cout<<1<<" ";
                                                                    else
                                                                        cout<<0<<" ";
                                                        }
                                                        else
                                                            back(k + 1, s, n, g);
                                                        s[k] = -1;
                                                    }
                                                }
                                            }
    
                                            int main(){
                                                int n, s[105] = {};
                                                bool g = false;
                                                cin>>n;
                                                for(int i = 0; i < n; i++)
                                                    s[i] = -1;
                                                back(0, s, n, g);
    
                                                if(!g)
                                                    cout<<"nu exista solutie";
                                            }