Advertisement
akanoce

Fiter

Jan 17th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. *int length_subc(nodo * L){
  2.     int lung = 1;
  3.     bool check = true;
  4.    
  5.     while(check && L){
  6.        
  7.         if(L->info <= L->next->info){
  8.             lung++;
  9.             L = L->next;
  10.         }//crescente
  11.         else
  12.         check = false;
  13.        
  14.     }//check
  15.    
  16.     return lung;
  17. }//length_subc
  18.  
  19. //PRE=(lista(L) corretta)
  20. doppioN Fiter(nodo*L){
  21.     doppioN maxsubseq_c;
  22.     int lung = 0;
  23.     bool inseq = false;
  24.     nodo * primo = L;
  25.    
  26.     while (L->next){
  27.     if(L->info <= L->next->info){
  28.        
  29.         if(lung<length_subc(L) && !inseq){
  30.             lung = 0;
  31.            maxsubseq_c.lung =  length_subc(L);
  32.             maxsubseq_c.inizio = L;
  33.             inseq = true;
  34.         } //crescente e non sono dentro la sequenza
  35.      lung++;  
  36.      L = L->next;
  37.        
  38.     }else{
  39.         if(inseq){
  40.             maxsubseq_c.fine = L;
  41.             inseq = false;        
  42.         }
  43.         L = L->next;
  44.     }//!crescente
  45.     }//L
  46.    
  47.     //maxsubseq_c.lung = lung;
  48.     return maxsubseq_c;
  49.    
  50. }//Fiter
  51. //POST=(restituisce il valore doppioN che rappresenta la sotto lista crescente di lunghezza massima di L)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement