#include <bits/stdc++.h>
using namespace std;
int main(){

    // Create & Initializing a vector;
    vector <int> a;
    vector <int> b(5,10); // Five integers with value of 10;
    vector <int> c(b.begin(),b.end());
    vector <int> d{1,2,30,10,4};
   
    // iterate over the vector
    cout<<"Print vector by iteration"<<endl;
    for (int i = 0; i < c.size(); i++)
    {
        /* code */
        cout<<c[i]<<endl;
    }
    cout<<endl;

    cout<<"With AUTO operator: "<<endl;
    for (auto it = b.begin(); it != b.end(); it++)
    {
        /* code */
        cout<<*it<<endl;
    }
    cout<<endl;

    cout<<"Without AUTO operator"<<endl;
    // Wihtout AUTO operator 
    for (vector <int> :: iterator it = b.begin(); it != b.end(); it++)
    {
        /* code */
        cout<<*it<<endl;
    }
    
    cout<<endl;

    cout<<"For EACH loop: "<<endl;
    for (int x: d)
    {
        /* code */
        cout<<x<<endl;
    }

    cout<<"Add values to the vector"<<endl; 
    // Add input from user & Add them to vector;
    vector <int> v;
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        /* code */
        int no;
        cin>>no;
        v.push_back(no); // Add elements to the end of the vector;
    }

    // Showing the value by for Each loop;
    for (int x:v)
    {
        /* code */
        cout<<x<<",";
    }
        cout<<endl;
        
    // Size & capacity of Vector V and Vector D
    cout<<"Size of vector v: "<<v.size()<<endl;
    cout<<"Capacity of vector v: "<<v.capacity()<<endl;
    cout<<"Max_Size of vector v: "<<v.max_size()<<endl;
    cout<<endl;

    cout<<"Size of vector d: "<<d.size()<<endl;
    cout<<"Capacity of vector d: "<<d.capacity()<<endl;
    cout<<"Max_Size of vector d: "<<d.max_size()<<endl;
    cout<<endl;

    // Vectors Methods
    cout<<"Elements of Vector d"<<endl;
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;
    d.pop_back();
    cout<<"After POP_BACK function"<<endl;
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;

    // Insert Some elements in the middle of the Vector
    d.insert(d.begin() + 3,100);
    cout<<"After Using insert function"<<endl;
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;

    // Multiple Insertion in the middle of the vector
    d.insert(d.begin() + 3,4,100);
    cout<<"After Inserting Multiple elements in the middle of the vector"<<endl;
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;
    
    // Erase some elements in the middle of the vector
    cout<<"After erasing single elements from the vector"<<endl;
    d.erase(d.begin() + 2); // 2 is here index
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;

    cout<<"After erasing multiple elements from the vector"<<endl;
    d.erase(d.begin() + 2, d.begin() + 5);
    for (int i : d)
    {
        /* code */
        cout<<i<<endl;
    }   
    cout<<endl;

    cout<<"Size of vector: "<<d.size()<<endl;
    cout<<"Capacity of vector: "<<d.capacity()<<endl;
    cout<<"Front element of vector d: "<<d.front()<<endl;
    cout<<"Back elements of vector d: "<<d.back()<<endl;

    // Sort the given elements
    sort(v.begin(),v.end());
    for (int i : v)
    {
        /* code */
        cout<<i<<endl;
    }
    cout<<endl;

        vector <int> li;
    li.push_back(30);
    li.push_back(120);
    li.push_back(22);
    cout<<"Size of the vector: "<<li.size()<<endl;
    for (int i : li)
    {
        /* code */
        cout<<i<<endl;
    }

    return 0;

}