summaryrefslogtreecommitdiff
path: root/list/task4.cpp
blob: c217664b1cfd695503b4578c8f345b864723d922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "list.h"

using namespace std;

void solve(list *&h, list *&t)
{
    list *cur = h;
    while (cur)
    {
        if (cur->inf % 2 == 0)
        {
            list *tmp = cur;
            cur = cur->next;
            del_node(h, t, tmp);
        }
        else cur = cur->next;
    }
}

int main()
{
    int n;
    cout << "n = ";
    cin >> n;

    list *head = NULL;
    list *tail = NULL;
    int x;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        push(head, tail, x);
    }

    solve(head, tail);
    print(head, tail);
    cout << endl;

    return 0;

}