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);    

 

 

 

 

 

 


 

 
posted @ 2020-05-29 09:26  海拉尔  阅读(3562)  评论(0编辑  收藏  举报