Académique Documents
Professionnel Documents
Culture Documents
{
char *locatia, *tara;
int distanta;
struct statiune *urm1;
struct statiune *urm2;
}nod;
nod*adauga2(nod*p, nod*q)
{
nod *q1, *q2;
for (q1 = q2 = p; q1 != NULL && q1->distanta > q-
>distanta; q2 = q1, q1 = q1->urm2);
q->urm2 = q1;
if (q1 == q2)
return q;
else
{
q2->urm2 = q;
return p;
}
}
void afis1(void)
{
nod *p;
for (p = prim1; p != NULL; p = p->urm1)
afisare(p);
}
void afis2(void)
{
nod *p;
for (p = prim2; p != NULL; p = p->urm2)
afisare(p);
}
if (q1 == q2)
return p->urm2;
else{
q2->urm2 = q1->urm2;
return p;
}
}
else
{
printf("Eroare nu apare in ev!");
return p;
}
}
void citire_fisier()
{
FILE *f;
nod *p;
char text[30]="";
char locatia[30] = "", tara[30] = "";
int distanta;
int c = 0,v;
f =fopen("vacanta.txt", "rt");
if (f == NULL)
printf("Fisierul nu a putut fi deschis!");
else{
while (fscanf(f,"%s",text)!=EOF)
if (strcmp(text, "|") == 0)
c++;
else
{
if (c % 3 == 0)
{
strcat(locatia, text);
strcat(locatia, " ");
}
if (c % 3 == 1)
{
strcat(tara, text);
strcat(tara, " ");
}
if (c % 3 == 2)
{
locatia[strlen(locatia) - 1] = '\0';
tara[strlen(tara) - 1] = '\0';
adaugare(locatia, tara, atoi(text));
strcpy(locatia, "");
strcpy(tara, "");
}
}
printf("\nDatele au fost Preluate\n");
fclose(f);
}
}