1 #include<iostream> 2 #include<string> 3 #include<vector> 4 5 int main() 6 { 7 using namespace std; 8 9 string s1; 10 string s2{"c plus plus"}; 11 string s3{s2}; 12 string s4=s2; 13 14 s1="oop"; 15 16 vector<string> v1; 17 v1.push_back(s1); 18 v1.push_back(s2+"1"); 19 v1.push_back(s3+"2"); 20 v1.push_back(s4+"3"); 21 22 cout<<"output1:"; 23 for(auto item:v1) 24 cout<<item<<endl; 25 26 27 cout<<"output2:"; 28 for(auto p=v1.begin();p!=v1.end();++p) 29 cout<<*p<<endl; 30 31 cout<<"output3:"; 32 for(auto i=0;i<v1.size();++i) 33 cout<<v1[i]<<endl; 34 35 36 vector<string> v2{v1.rbegin(),v1.rend() }; 37 cout<<"v2:"<<endl; 38 for(auto item :v2) 39 cout<<item<<endl;
40 }
标签:string,s2,s1,back,v1,任务,实验,push From: https://www.cnblogs.com/zxy0324/p/16738697.html