Advertisement
joaoantoniodornelas

Lista 1 - Questão 1.1

Apr 18th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. int nElementos(No* p){
  2.     if(p->prox == NULL){
  3.         return 1;
  4.     }
  5.     else{
  6.         return 1 + nElementos(p->prox)
  7.     }
  8. }
  9.  
  10. int nElementos(No* p){
  11.     if(p == NULL)
  12.         return 0;
  13.     int cont = 0;
  14.     No* x = *p;
  15.     while(x != NULL){
  16.         cont++;
  17.         x = x->prox;
  18.     }
  19.     return cont;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement