Untitled

mail@pastecode.io avatar
unknown
c_cpp
5 days ago
696 B
1
Indexable
Never
#include <iostream>
#include <vector>

int main()
{
    std::vector< int > vec1{ 1, 2, 3, 4, 5 };

    auto firstElement = vec1.front();
    std::cout << "Pierwszy element w wektorze: " << firstElement << "\n\n";

    auto lastElement = vec1.back();
    std::cout << "Ostatni element w wektorze: " << lastElement << "\n\n";

    for( const auto& v : vec1 )
    {
        std::cout << v << " ";
    }
    std::cout << "\n\n";

    vec1.insert( vec1.begin() + 2, 105 );
    vec1.insert( vec1.begin(), -3 );
    vec1.insert( vec1.begin() + 5, -23 );

    for( const auto& v : vec1 )
    {
        std::cout << v << " ";
    }
    std::cout << "\n\n";

    return 0;
}
Leave a Comment