• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            積木

            No sub title

              C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              140 Posts :: 1 Stories :: 11 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(1)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            以下是Vector容器用戶總結(jié)

            ---------------------------------------------------------------------------------------------------
            幾個介紹vector容器還不錯的文章鏈接:
                http:
            //blog.csdn.net/fm0517/archive/2009/06/09/4254099.aspx

            ---------------------------------------------------------------------------------------------------

            // Test_20110513_1036.cpp : Defines the entry point for the console application.
            //

            #include 
            "stdafx.h"

            #include 
            <vector>
            #include 
            <iostream>
            using namespace std;

            int _tmain(int argc, _TCHAR* argv[])
            {
                
            //創(chuàng)建vector容器
                vector<int> vInt;
                
            //也可以下面這樣初始化,表示將所有的元素初始化為
                
            //vector<int> vInt(0);
                
            //添加元素
                for (vector<int>::value_type i = 0; i < 10; i++)
                    vInt.push_back(i 
            + 1);
                
            //輸出元素
                cout << "-------------------------------------------------------" << endl << "操作:添加元素" << endl;
                
            for (vector<int>::iterator iter = vInt.begin(); iter != vInt.end(); iter++)
                    cout 
            << *iter << endl;
                
                
            //erase操作----其實就是刪除指定的某個元素
                cout << "-------------------------------------------------------" << endl << "操作:erase操作" << endl;
                
            for (vector<int>::iterator iter3 = vInt.begin(); iter3 != vInt.end(); iter3++)
                {
                    
            if (*iter3 == 8)
                    {
                        iter3 
            = vInt.erase(iter3);
                        
            break;
                    }
                }
                
            for (vector<int>::iterator iter4 = vInt.begin(); iter4 != vInt.end(); iter4++)
                    cout 
            << *iter4 << endl;

                
            //刪除最后一個元素,方法一
                cout << "-------------------------------------------------------" << endl << "操作:刪除最后一個元素之方法一" << endl;
                
            if (vInt.size() > 0)
                {
                    vector
            <int>::iterator iterEnd = vInt.end() - 1;
                    
            /*iterEnd = */vInt.erase(iterEnd);
                    
            //輸出
                    for (vector<int>::iterator iter5 = vInt.begin(); iter5 != vInt.end(); iter5++)
                        cout 
            << *iter5 << endl;
                }

                
            //刪除最后一個元素,方法二
                cout << "-------------------------------------------------------" << endl << "操作:刪除最后一個元素之方法二" << endl;
                
            if (vInt.size() > 0)
                {
                    vector
            <int>::iterator iterEnd2 = vInt.end() - 1;
                    vInt.pop_back();
                    
            //輸出
                    for (vector<int>::iterator iter5 = vInt.begin(); iter5 != vInt.end(); iter5++)
                        cout 
            << *iter5 << endl;
                }

                
            //清空所有數(shù)據(jù)元素
                vInt.clear();
                
            //輸入元素
                cout << "-------------------------------------------------------" << endl << "操作:清空元素" << endl;
                
            for (vector<int>::iterator iter2 = vInt.begin(); iter2 != vInt.end(); iter2++)
                    cout 
            << *iter2 << endl;

                
            return 0;
            }



            以下是執(zhí)行結(jié)果:
                 

            posted on 2011-07-04 20:29 Jacc.Kim 閱讀(511) 評論(0)  編輯 收藏 引用 所屬分類: VC / C++
            久久久无码精品午夜| 亚洲综合婷婷久久| 久久久久亚洲AV成人网| 久久精品国产亚洲av瑜伽| 9久久9久久精品| 久久亚洲色一区二区三区| 超级碰碰碰碰97久久久久| 漂亮人妻被中出中文字幕久久| 久久午夜福利无码1000合集| 香港aa三级久久三级| 日本欧美国产精品第一页久久| 久久久久亚洲AV无码观看 | 国产精品免费久久久久久久久| 久久精品国产一区二区电影| 国产福利电影一区二区三区,免费久久久久久久精 | 日产精品久久久一区二区| 91性高湖久久久久| 久久综合久久美利坚合众国| 亚洲国产成人久久综合碰碰动漫3d| 亚洲Av无码国产情品久久| 亚洲AV无码一区东京热久久| 亚洲人成网站999久久久综合| 久久久久99精品成人片三人毛片 | 狠狠色婷婷久久综合频道日韩| 狠狠色伊人久久精品综合网| 久久久av波多野一区二区| 亚洲综合伊人久久综合| 一本大道久久香蕉成人网| 精品久久久久久国产| 精品久久久久久99人妻| 久久精品成人免费网站| 99久久久精品免费观看国产| 国内精品伊人久久久久av一坑| 久久妇女高潮几次MBA| 精品久久久无码中文字幕| Xx性欧美肥妇精品久久久久久| 91久久精品电影| 精品国产一区二区三区久久蜜臀| 国产高潮久久免费观看| 国产99久久久久久免费看| 久久精品无码专区免费|