Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 06 / reverse.cpp
diff options
context:
space:
mode:
Commitae90cb76ace17c6a2b0bee34d151242855ca5bab (patch)
Author
 Angel Dimitriev <achi_d@abv.bg>
2021-11-15 16:52:00 +0200
Committer
 GitHub <noreply@github.com>
2021-11-15 16:52:00 +0200
Files5b423fb84a8487562376d04011677b9e09ea4312 /Sem. 06/reverse.cpp
Introduction_to_programming_FMI-ae90cb76ace17c6a2b0bee34d151242855ca5bab.tar
Introduction_to_programming_FMI-ae90cb76ace17c6a2b0bee34d151242855ca5bab.tar.gz
Introduction_to_programming_FMI-ae90cb76ace17c6a2b0bee34d151242855ca5bab.zip
Parent2a0469e65b9d4e0dde42656c199c7dd477e7e139 (diff)
Add files via upload
1 files changed, 23 insertions, 0 deletions
-rw-r--r--Sem. 06/reverse.cpp23
diff --git a/Sem. 06/reverse.cpp b/Sem. 06/reverse.cpp
new file mode 100644
index 0000000..e239289
--- /dev/null
+++ b/Sem. 06/reverse.cpp
@@ -0,0 +1,23 @@
+#include <iostream>
+using namespace std;
+
+void swap(int& x, int& y)
+{
+ int temp = x;
+ x = y;
+ y = temp;
+}
+
+void reverse(int arr[], unsigned size)
+{
+ for (unsigned i = 0; i < size / 2; i++)
+ swap(arr[i], arr[size - 1 - i]);
+}
+
+int main()
+{
+ int arr[] { 1, 2, 3, 4,5,6,7,8};
+ reverse(arr, 8);
+ print(arr, 8);
+}
+