Skip to content

Commit f490010

Browse files
authored
IOTA ALGORITHM
1 parent 22b00a3 commit f490010

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Diff for: IncrementingAlgorithm/iota.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
#include <vector>
3+
template<typename ForwardIt, typename T>
4+
//////IOTA ALGORITHM//////
5+
void iota(ForwardIt first, ForwardIt last, T value)
6+
{
7+
while(first != last) {
8+
*first++ = value;
9+
++value;
10+
}
11+
}
12+
13+
int main(){
14+
int take;
15+
std::cout << "What size of vector would you like ? ";
16+
std::cin >> take;
17+
std::vector<int> vec(take);
18+
std::cout << "VECTOR : [ " << vec.at(0) << " ] (BEFORE)\n";
19+
std::cout << "What integer would you like to start incrementing from ? ";
20+
std::cin >> take;
21+
iota(vec.begin(), vec.end(), take);
22+
std::cout << "VECTOR : [ ";
23+
for(const auto &a:vec)
24+
std::cout << a << " ";
25+
std::cout << "] (AFTER)\n";
26+
return 0;
27+
}

0 commit comments

Comments
 (0)