日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

STL vector

發(fā)布時間:2024/8/22 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 STL vector 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
View Code 1 #include<iostream>
2 #include<vector>
3 #include<string>
4
5 using namespace std;
6
7
8 int main()
9
10 {
11
12 vector<int> ivec;//空!大小為零
13 cout << ivec.size() <<endl;
14
15 cout<<"請輸入5個整數(shù)"<<endl;
16 int k;
17 for(vector<int>::size_type ix =0; ix!=5;++ix)
18 { // cin << ivec[ix]; 這種寫法是錯的,如果要使用下標,必須要已經(jīng)由下標才行,空表則不可以!想用下標先給表賦值或……
19 cin >> k;
20 ivec.push_back(k);
21
22 }
23 cout<<"顯示vector里的數(shù)據(jù)"<<endl;
24
25 for(vector<int>::size_type m=0; m!=ivec.size() ;++m)
26 {
27
28 cout<< ivec[m]<<endl;
29
30 }
31
32
33 cout<<"下面請輸入一些字符串"<<endl;
34
35 string word;
36 vector<string> text;
37 while(cin >> word)
38 text.push_back(word);
39
40
41 cout<<"你輸入的字符串是:"<<endl;
42
43 for(vector<string>::size_type n=0 ;n!=text.size(); ++n)
44 cout << text[n]<<endl;
45
46
47 return 0;
48 }


編輯器加載中...

轉載于:https://www.cnblogs.com/uniquews/archive/2012/03/27/2420388.html

總結

以上是生活随笔為你收集整理的STL vector的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。