vector

    xiaoxiao2021-04-16  248

    #include <iostream> #include<vector> using namespace std; int main() { vector<int>myprint; for(int i=1;i<11;i++) myprint.push_back(i); //auto高级遍历 for(auto & a : myprint) cout<<a<<' '; cout<<endl; //auto一般遍历 for(auto a = myprint.begin();a!=myprint.end();++a) cout<<*a<<' '; cout<<endl; //普通迭代器遍历 for(vector<int>::iterator a=myprint.begin();a!=myprint.end();++a) cout<<*a<<' '; cout<<endl; return 0; } /* Output:1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 */

    最新回复(0)