#include <iostream> #include <string> #include <vector> int main() { using namespace std; string s1; string s2{"c plus plus"}; string s3{s2}; string s4=s2; s1="oop"; vector<string>v1; v1.push_back(s1); v1.push_back(s2+"1"); v1.push_back(s3+"2"); v1.push_back(s4+"3"); cout<<"output1: "<<endl; for(auto item: v1){ cout<<item<<endl; } cout<<"output2: "; for(auto p=v1.begin();p!=v1.end();++p){ cout<<*p<<endl; } cout<<"output3: "; for(auto i=0;i<v1.size();++i){ cout<<v1[i]<<endl; } vector<string>v2{v1.rbegin(),v1.rend()}; cout<<"v2: "<<endl; for(auto item:v2){ cout<<item<<endl; } }
标签:1.1,s2,s1,back,v1,vector,push,string From: https://www.cnblogs.com/gzj035/p/16738628.html