Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void inserare(nod * & p) {
- if (p->urm == NULL && p->info % 2 == 0) { // verific daca lista are un singur element si daca acesta esta par
- nod* tmp = new nod;
- tmp->info = p->info * 2;
- tmp->urm = p;
- p = tmp;
- } else {
- nod *it = p;
- while (it->urm != NULL) {
- if(it->urm->info % 2 == 0) {
- nod *tmp = new nod;
- tmp->info = it->urm->info * 2;
- tmp->urm = it->urm;
- it->urm = tmp;
- it = tmp->urm; // ma pozitionez pe elementul par inaintea caruia am creeat dublul sau
- } else {
- it = it->urm;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement