Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 09 / task6.cpp
diff options
context:
space:
mode:
1 files changed, 18 insertions, 0 deletions
-rw-r--r--pract_SI/Pract. 09/task6.cpp18
diff --git a/pract_SI/Pract. 09/task6.cpp b/pract_SI/Pract. 09/task6.cpp
new file mode 100644
index 0000000..a380fb2
--- /dev/null
+++ b/pract_SI/Pract. 09/task6.cpp
@@ -0,0 +1,18 @@
+#include <vector>
+
+void insertIntoVector(std::vector<int>& arr, int number, int index)
+{
+ if (arr.empty() || arr.size() <= index) //insert @end
+ {
+ arr.push_back(number);
+ return;
+ }
+
+ if (arr[index] > number)
+ {
+ arr.insert(arr.begin() + index, number);
+ return;
+ }
+
+ return insertIntoVector(arr, number, ++index);
+}