uibk_703807-Advanced-CXX/exercises/task04/iterations.cpp

20 lines
325 B
C++
Raw Permalink Normal View History

2020-10-22 12:46:23 +02:00
#include <iostream>
#include <vector>
int main()
{
std::vector<int> xs{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
for (auto it = xs.begin(); it != xs.end(); ++it) {
for (int i = 0; i < *it; i++) {
xs.push_back(*it);
}
}
std::cout << "Vector: ";
for (const auto &x : xs) {
std::cout << x << " ";
}
std::cout << "\n";
}