summaryrefslogtreecommitdiff
path: root/list/task4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'list/task4.cpp')
-rw-r--r--list/task4.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/list/task4.cpp b/list/task4.cpp
new file mode 100644
index 0000000..c217664
--- /dev/null
+++ b/list/task4.cpp
@@ -0,0 +1,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;
+
+}