summaryrefslogtreecommitdiff
path: root/structures/task14.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'structures/task14.cpp')
-rw-r--r--structures/task14.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/structures/task14.cpp b/structures/task14.cpp
new file mode 100644
index 0000000..fcd9d63
--- /dev/null
+++ b/structures/task14.cpp
@@ -0,0 +1,45 @@
+#include <iostream>
+#include "queue.h"
+
+using namespace std;
+
+void result(queue *&h, queue *&t, queue *&hr, queue *&tr)
+{
+ while (h)
+ {
+ int el = char(pop(h, t));
+ if ( '0' <= el && el <= '9'
+ || 'a' <= el && el <= 'z'
+ || 'A' <= el && el <= 'Z' )
+ {
+ push(hr, tr, int(el));
+ }
+ }
+}
+
+int main()
+{
+ int n;
+ cout << "n = ";
+ cin >> n;
+
+ queue *head = NULL;
+ queue *tail = NULL;
+ char x;
+ for (int i = 0; i < n; i++)
+ {
+ cin >> x;
+ push(head, tail, int(x));
+ }
+
+ queue *head_res = NULL;
+ queue *tail_res = NULL;
+
+ result(head, tail, head_res, tail_res);
+ while (head_res)
+ cout << char(pop(head_res, tail_res)) << " ";
+ cout << endl;
+
+ return 0;
+
+}