Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *int length_subc(nodo * L){
- int lung = 1;
- bool check = true;
- while(check && L){
- if(L->info <= L->next->info){
- lung++;
- L = L->next;
- }//crescente
- else
- check = false;
- }//check
- return lung;
- }//length_subc
- //PRE=(lista(L) corretta)
- doppioN Fiter(nodo*L){
- doppioN maxsubseq_c;
- int lung = 0;
- bool inseq = false;
- nodo * primo = L;
- while (L->next){
- if(L->info <= L->next->info){
- if(lung<length_subc(L) && !inseq){
- lung = 0;
- maxsubseq_c.lung = length_subc(L);
- maxsubseq_c.inizio = L;
- inseq = true;
- } //crescente e non sono dentro la sequenza
- lung++;
- L = L->next;
- }else{
- if(inseq){
- maxsubseq_c.fine = L;
- inseq = false;
- }
- L = L->next;
- }//!crescente
- }//L
- //maxsubseq_c.lung = lung;
- return maxsubseq_c;
- }//Fiter
- //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