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

#include <stdio.h>

int* get_max(int n, int *v) {
        if (n == 0)
                return NULL;
        int i;
        int max = *v, *pmax = v; //max retine valoarea lui v[0], iar pmax retine un pointer la inceputul vectorului
        for(i = 1; i < n; i++) {
                v++;
                if (*v > max) {
                        max = *v;
                        pmax = v;
                        }
                }
        return pmax;
}

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

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

        int* poz = get_max(n, v);

        if (poz != NULL)  printf("%p\n%d\n", poz, *poz);        
        else printf("Vectorul are 0 elemente.\n"); //daca am incerca sa accesam poz, am primi Segmentation fault pentru ca poz este NULL in acest caz

        return 0;
}


/*
 * Problema 3
 */

#include <stdio.h>

void count(int n, int *v, int *zero, int *poz, int *neg){
        int i;
        *zero = *poz = *neg = 0;
        for(i = 0; i < n; i++)
                if (v[i] == 0)
                        (*zero)++;
                else 
                        if (v[i] < 0)
                                (*neg)++;
                        else
                                (*poz)++;
}

int main(){
        
        int v[100], i, n;
        int po = 0, ne = 0, ze = 0;    

        //printf("n=");
        scanf("%d", &n);
        for(i = 0; i < n; i++)
                scanf("%d", &v[i]);
        count(n, v, &ze, &po, &ne);
        printf("zero : %d\npoz : %d\nneg : %d\n", ze, po, ne);
        return 0;
}


/*
 * Problema 4
 */

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

char* strdel(char* p, int n)
{
        //caz 1: nu exista mai mult de n caractere incepand de la pozitia p
        if (strlen(p) <= n) {
                *p = '\0';
                return p;
                }

        //in caz contrar, facem stergerea copiind caracterele de la p+n peste cele de la p
        strcpy(p, p + n);
        return p;
}

char* strins(char* p, char *s)
{
        //pas 1: copiem sirul din p intr-o alta locatie
        char *tail_p = strdup(p);

        //pas 2: copiem la pozitia p noul sir
        strcpy(p, s);

        //pas 3: copiem la sfarsit caracterele care existau inainte in p
        strcat(p, tail_p);

        return p;
}

int main()
{
        char s[100],replacethis[100],withthis[100];

        
        gets(s);
        scanf("%s %s", replacethis, withthis);

        char *p;

        // pornim cu p fiind prima aparitie a sirului <replacethis> in sirul <s>
        // atata timp cat mai exista aparitii, facem inlocuirea si setam "p" ca fiind adresa urmatoarei
        // aparitii a sirului <replacethis> in <s>
        //
        // ATENTIE! este foarte important sa dam p=strstr(p+strlen(withthis),...) pentru ca in caz contrar programul ar cicla la infinit daca sirul <replacethis> se regaseste in <withthis>
        // Cu alte cuvinte, am inlocui in inlocuire, in locuire, in inlocuire...
        for (p = strstr(s, replacethis); p != NULL; p = strstr(p + strlen(withthis), replacethis)){
                strdel(p, strlen(replacethis));
                strins(p, withthis);
        }

        printf("%s\n", s);      

        return 0;
}



/* 
 * Problema 5
 */

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

char* substr(char* src, int n, char* dest)
{
        strncpy(dest, src, n);
        if (n <= strlen(src))
                dest[n] = '\0';
        return dest;
}

int main()
{
        char s[100],subs[100];
        int poz,len;

        scanf("%s %d %d",s, &poz, &len);

        substr(s + poz, len, subs);

        printf("%s",subs);

        printf("\n");

        return 0;
}



/*
 * Problema 6
 */

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

int strdcmp(char* s1, char* s2)
{
        int l1 = strlen(s1), l2 = strlen(s2);
        if (l1 < l2) return -1;
        if (l1 > l2) return 1;
        while ((*s1) == (*s2) && (*s1) != '\0'){
                s1++;
                s2++;
                }
        if ((*s1) < (*s2)) return -1;
        if ((*s1) > (*s2)) return 1;
        return 0;
}

int readint()
{
        char buff[100], int_max[100];
        sprintf(int_max, "%d", INT_MAX);
        scanf("%s", buff);
        if (strdcmp(buff, int_max) == 1) return -INT_MAX;
        return atoi(buff);
}

int main()
{
        int n = readint();
        
        printf("%d\n",n);

        return 0;
}



/*
 * Problema 7
 */

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

char* next(char* from, char* word)
{
        //pas 1: sarim peste caracterele care sunt diferite de '\0' sau de litere mici
        while ((*from) != '\0' && ((*from) < 'a' || (*from) > 'z')) from++;

        //daca nu mai sunt litere in from
        if ((*from) == '\0') return NULL;
        
        //pas 2: sarim peste litere
        char *p = from;
        while ((*p) != '\0' && (*p) >= 'a' && (*p) <= 'z') p++;

        //pas 3: copiem in word (p-from) caractere
        strncpy(word, from, p - from);
        word[p - from] = '\0';

        return p;
}

int main()
{
        char buff[100], *p, cuv[100];

        gets(buff);

        for (p = next(buff, cuv); p != NULL; p = next(p, cuv))
                printf("%s ", cuv);

        printf("\n");

        return 0;
}


/*
 * Problema 8
 */

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

# define EPS 1e-5

void panta(int x1, int y1, int x2, int y2, float *m, float *n)
{
        if (x1 == x2){
                *m = INT_MAX;
                *n = 0;
                return;
        }

        if (x2 < x1){
                panta(x2, y2, x1, y1, m, n);
                return;
        }

        *m = ((float)(y2 - y1)) / (x2 - x1);
        *n = y1 - (*m) * x1;
}

int main()
{
        int x1, x2, y1, y2, xverif, yverif;
        float m1, m2, n1, n2;

        //printf("Primul punct: ");
        scanf("%d%d", &x1, &y1);

        //printf("Al doilea punct: ");
        scanf("%d%d", &x2, &y2);

        //printf("Punctul de verificare: ");
        scanf("%d%d", &xverif, &yverif);

        panta(x1, y1, x2, y2, &m1, &n1);
        panta(x1, y1, xverif, yverif, &m2, &n2);

        if (abs(m1 - m2) <= EPS)
                printf("DA\n");
        else
                printf("NU\n");

        return 0;
}



/*
 * Problema 9
 */

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

void incrementeaza_timp(int *h, int *m, int *s, char *sufix)
{
        (*s)++;

        sufix[0] = toupper(sufix[0]);
        sufix[1] = toupper(sufix[1]);

        if (*s > 59) {
                *s = 0;
                (*m)++;
                }
        else return;

        if (*m > 59) {
                *m = 0;
                (*h)++;
                }
        else return;

        if (sufix[0] == 'P' && *h >= 12) {
                *h = 0;
                sufix[0] = 'A';
                return;
                }

        if (sufix[0] == 'A' && *h >= 13) {
                *h = 1;
                sufix[0] = 'P';
                return;
                }
}

int main()
{
        int h,m,s;
        char sufix[3];

        scanf("%d %d %d %s", &h, &m, &s, sufix);

        incrementeaza_timp(&h, &m, &s, sufix);

        printf("%02d:%02d:%02d %s\n",h, m, s, sufix);

        return 0;
}