summaryrefslogtreecommitdiff
path: root/structures/task8.cpp
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2021-02-11 00:10:23 +0400
committerAndrew <saintruler@gmail.com>2021-02-11 00:10:23 +0400
commit17a4c9f6e0380aae2366b33628fae0ef722ec762 (patch)
tree2b3b0b654ece4cd7c83215c2367148044dc3c1ac /structures/task8.cpp
parentbc035ad7c41828f27c7cd9605a0b4f1683de65d4 (diff)
Немного рефакторинга
Diffstat (limited to 'structures/task8.cpp')
-rw-r--r--structures/task8.cpp11
1 files changed, 6 insertions, 5 deletions
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;