0
//function of inserting there; there only does it with the 3 first names, the others it does not order
Aluno *cad(Aluno *aluno)
{
Aluno *aux;
while(1)
{
aux = aluno;
if(aux->prox == NULL)
{
Aluno *criar = novo();
if(criar == NULL)
{
break;
}
if(strcmp(aux->nome, criar->nome) > 0)
{
criar->prox = aux;
aux = criar;
}
else
{
aux->prox = criar;
}
}
else
{
Aluno *criar = novo();
if(criar == NULL)
{
break;
}
Aluno *aux2;
Aluno *aux3 = aux;
while(aux3->prox != NULL)
{
printf("1\n");
aux2 = aux3->prox;
if(strcmp(criar->nome, aux3->nome) > 0)
{
printf("entrei no if\n");
criar->prox = aux2;
aux3->prox = criar;
break;
}
aux3 = aux3->prox;
}
if(aux3->prox == NULL)
{
aux3->prox = criar;
}
}
aluno = aux;
}
return aluno;
}
thanks friend, helped me mt!
– Prog
What is cmpAtual and Previous?
– Maurício Z.B
It goes like this: if the list contains { Antonia, Antonio, Bonifacio, Jose } and the item to be included is Joao, the comparisons will give { +1, +1, +1, -1 }. The logic of the program is prepared to treat only those cases where the relative comparison between elements of the list changes, among other exceptions.
– Marcelo Shiniti Uchimura