Advertisement
ElizeuSandro

Untitled

Jan 26th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. noLista* insertionSort(noLista *ini, int tam){
  2. int num;
  3. noLista *aux;
  4. noLista *aux2;
  5. aux = ini-> prox;
  6. char nomeA[30];
  7.  
  8.  
  9. while (aux != NULL){
  10. num = aux->nota;
  11. strcpy(nomeA ,aux->nome);
  12. aux2 = aux->ant;
  13.  
  14. while(aux2 != NULL && aux2->nota > num){
  15. aux2->prox->nota = aux2->nota;
  16. strcpy(aux2->prox->nome, aux2->nome);
  17. strcpy(aux2->nome, nomeA);
  18. aux2 = aux2->ant;
  19. }
  20.  
  21. if (aux2 == NULL){
  22.  
  23. ini->nota = num;
  24. strcpy(ini->nome, nomeA);
  25.  
  26. }else{
  27. aux2->prox->nota = num;
  28.  
  29. strcpy(nomeA, aux2->prox->nome);
  30. }
  31. aux = aux->prox;
  32.  
  33. }
  34. return ini;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement