Advertisement
Guest User

Invert List

a guest
May 15th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct lista {
  5.     int info;
  6.     struct lista *prox;
  7. }TLSE;
  8.  
  9. int func(TLSE * l,int distance,int pass){
  10.     if(!l) return -1;
  11.     if(!distance) l->info = pass;
  12.     l->info = func(l->prox,distance-1,l->info);
  13. }
  14.  
  15. void invertList(TLSE * l){
  16.     if(!l)return;
  17.     TLSE * k = l;
  18.     int size = 0;
  19.     while(l){
  20.         l = l->prox
  21.         size++;
  22.     }
  23.     func(k,size,-1);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement