summaryrefslogtreecommitdiff
path: root/structures
diff options
context:
space:
mode:
Diffstat (limited to 'structures')
-rw-r--r--structures/task5.cpp11
-rw-r--r--structures/task8.cpp11
2 files changed, 12 insertions, 10 deletions
diff --git a/structures/task5.cpp b/structures/task5.cpp
index f182625..56bcb17 100644
--- a/structures/task5.cpp
+++ b/structures/task5.cpp
@@ -3,7 +3,7 @@
using namespace std;
-stack *result(stack *&h)
+void solve(stack *&h)
{
stack *tmp = NULL;
stack *res = NULL;
@@ -26,7 +26,7 @@ stack *result(stack *&h)
push(res, elem);
}
- return res;
+ h = res;
}
int main()
@@ -42,9 +42,10 @@ int main()
push(head, int(x));
}
reverse(head);
- stack *res = result(head);
- while (res)
- cout << char(pop(res)) << " ";
+
+ solve(head);
+ while (head)
+ cout << char(pop(head)) << " ";
cout << endl;
return 0;
diff --git a/structures/task8.cpp b/structures/task8.cpp
index 15832d2..c0542a8 100644
--- a/structures/task8.cpp
+++ b/structures/task8.cpp
@@ -3,7 +3,7 @@
using namespace std;
-stack *result(stack *&h)
+void solve(stack *&h)
{
stack *res = NULL;
@@ -30,7 +30,7 @@ stack *result(stack *&h)
}
reverse(res);
- return res;
+ h = res;
}
int main()
@@ -46,9 +46,10 @@ int main()
push(head, x);
}
reverse(head);
- stack *res = result(head);
- while (res)
- cout << pop(res) << " ";
+
+ solve(head);
+ while (head)
+ cout << pop(head) << " ";
cout << endl;
return 0;