Редактирование Односвязного списка C++

Ранее делал через Классы, но сейчас стоит задача с помощью структур. Совсем не получается реализовать 2 функции.

  1. Разработать функцию, которая удаляет из списка все узлы в четных позициях.
  2. Разработать функцию, которая вставляет в список L2 после каждой пары узлов новый узел со значением равным сумме значений двух предыдущих узлов.
#include <iostream>
#include <fstream>
using namespace std;

struct list
{
    int value = 0;
    list* next = NULL;
    void deleteNextElement()
    {
        if (next != NULL)
        {
            list* temp = next;
            next = temp->next;
            delete temp;
        }
    }
};

list* addnode(list* root, int newvalue)
{
    if (root != NULL)
    {
        list* newnode = new list;
        newnode->value = newvalue;

        list* i = root;
        while (i->next != NULL)
        {
            i = i->next; 
        }
        i->next = newnode;
    }
    else
    {
        root = new list;
        root->value = newvalue;
    }
    return root;

}
struct list* deletelem(list* root2)
{
    list* q, * s;
    s = root2;
    if (s != NULL)
    {
        while (s != NULL) {
            if (s->next->value < 0) {
                q = s;s = s->next;
                delete q;
            }
            else {
                s = s->next;
            }
        }
    }
    return root2;
}
int getSize(list* root)
{
    int size = 1;
    list* i = root;
    while (i->next != NULL)
    {
        size++;
        i = i->next;
    }
    //cout << size<<endl;
    return size;
}
void printlist(list* root)
{
    if (root != NULL)
    {
        list* i = root;
        cout << i->value << " ";
        while (i->next != NULL)
        {
            i = i->next;
            cout << i->value << " ";
        }
        cout << endl;
    }
    else cout << "Список пуст!";
}

list* addeq(list* root1, list* root2, list* root3)
{
    if (root1 != NULL)
    {
        list* i = root1;
        while (i->next != NULL)
        {
            root3 = addnode(root3, i->value);

            i = i->next;
            if (i->next == NULL)
                root3 = addnode(root3, i->value);
        }
    }
    if (root2 != NULL)
    {
        
            list* j = root2;
            while (j->next != NULL)
            {
                root3 = addnode(root3, j->value);
                j = j->next;
                if(j->next == NULL)
                    root3 = addnode(root3, j->value);
            }
    }
    return root3;
}
void insert(list* root) // РЕАЛИЗОВАТЬ ВСТАВКУ ПОСЛЕ 2УХ
{

}
void delChet(list* root) // УДАЛЕНИЕ В ЧЕТНЫХ УЗЛАХ
{

}
list* unique(list* lst) 
{
    list* t, * q, * p = lst, * i = lst;
    while (p != NULL) 
    {
        for (t = i = p->next; i != NULL; ) 
        {
            if (i->value == p->value) 
            {
                q = i->next;
                if (t == i)
                    t = p->next = i->next;
                else
                    t->next = i->next;

                delete i;
                i = q;
                continue;
            }
            t = i;
            i = i->next;
        }
        p = p->next;
    }
    return lst;

Ответы (0 шт):