SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void inserare(nod * & p) {
  2.     if (p->urm == NULL && p->info % 2 == 0) { // verific daca lista are un singur element si daca acesta esta par
  3.         nod* tmp = new nod;
  4.         tmp->info = p->info * 2;
  5.         tmp->urm = p;
  6.         p = tmp;
  7.     } else {
  8.         nod *it = p;
  9.         while (it->urm != NULL) {
  10.             if(it->urm->info % 2 == 0) {
  11.                 nod *tmp = new nod;
  12.                 tmp->info = it->urm->info * 2;
  13.                 tmp->urm = it->urm;
  14.                 it->urm = tmp;
  15.                 it = tmp->urm; // ma pozitionez pe elementul par inaintea caruia am creeat dublul sau
  16.                
  17.             } else {
  18.                 it = it->urm;
  19.             }
  20.         }
  21.     }
  22. }
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