1 #include <iostream> 2 #include <string> 3 #include <vector> 4 using std::string; 5 using std::vector; 6 using namespace std; 7 void bline(); 8 9 int main() 10 { 11 //3.16 12 vector<int> v1; 13 vector<int> v2(10); 14 vector<int> v3(10,42); 15 vector<int> v4{10}; 16 vector<int> v5{10,42}; 17 vector<string> v6{10}; 18 vector<string> v7{10,"hi"}; 19 20 bline(); 21 cout<<v2.size()<<endl; 22 for(int &i : v2)cout<<i<<endl; 23 bline(); 24 cout<<v3.size()<<endl; 25 for(int &i : v3)cout<<i<<endl; 26 bline(); 27 cout<<v4.size()<<endl; 28 for(int &i : v4)cout<<i<<endl; 29 bline(); 30 cout<<v5.size()<<endl; 31 for(int &i : v5)cout<<i<<endl; 32 bline(); 33 cout<<v6.size()<<endl; 34 for(string &i : v6)cout<<i<<endl; 35 bline(); 36 cout<<v7.size()<<endl; 37 for(string &i : v7)cout<<i<<endl; 38 bline(); 39 //3.17 40 string temp; 41 vector<string> word; 42 while(cin>>temp){ 43 for(char &c:temp)c=toupper(c); 44 word.push_back(temp); 45 } 46 for(string tmp:word)cout<<tmp<<endl; 47 48 return 0; 49 } 50 51 void bline(){ 52 cout<<"------"<<endl; 53 }
原文:http://www.cnblogs.com/austuode/p/4435224.html