Vector 使用数组初始化


vector 使用数组地址初始化时,为左闭右开

int a[4] = {1,2,3,4};

vector<int> st(a, a+3);

不包含a[3]



int a[4] = {1,2,3,4};

vector<int> st(a+1, a+4);

依旧左闭右开

通过insert的方式也遵循左闭右开

    int a[4] = {1,2,3,4};
        vector<int> st;
    st.insert(st.begin(),a+1,a+3);    



 
原文地址:https://www.cnblogs.com/9527s/p/12985538.html