Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 09 / task6.cpp
blob: a380fb2f8bc1ec7e5f1bd58e46658afa38c83cd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
}