SHARE
TWEET

Untitled

a guest Jun 25th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include "lista.h"
  3.  
  4. int maior(Lista* l, int n);
  5. int maior_rec(Lista* l, int n);
  6.  
  7. int main(){
  8.    
  9.     Lista* L = no(1,no(2,no(3,no(4,no(5,no(6,NULL))))));
  10.     int n;
  11.    
  12.     exibe(L);
  13.    
  14.     printf("\nDigite um valor: "); 
  15.     scanf("%d",&n);
  16.    
  17.     printf("Possui %d nos com numeros maiores que %d!",maior_rec(L,n),n);
  18.    
  19.     return 0;
  20. }
  21.  
  22. int maior(Lista* l, int n){
  23.     Lista* p;
  24.     int m = 0;
  25.     for(p=l;p!=NULL;p = p->prox){
  26.         if(p->info > n){
  27.             m++;
  28.         }
  29.     }
  30.     return m;
  31. }
  32.  
  33. int maior_rec(Lista* l, int n){
  34.     int m = 0;
  35.     Lista* p = l;
  36.     if(p->info > n){
  37.         m++;
  38.     }
  39.     if(p->prox!=NULL)
  40.         m += maior_rec(p->prox,n);
  41.    
  42.     return m;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top