青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

T9的空間

You will never walk alone!

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  69 隨筆 :: 0 文章 :: 28 評論 :: 0 Trackbacks

#

 1/*
 2  Name: build priority_queue
 3  Copyright: 
 4  Author: Torres
 5  Date: 29-08-08 10:48
 6  Description: 建立優(yōu)先隊列的方法 
 7*/

 8#include<iostream>
 9#include<vector>
10#include<queue>
11using namespace std;
12template<class T>void print(T &a){while(!a.empty()){cout<<a.top()<<" ";a.pop();}cout<<endl;}
13typedef struct node{
14    int x,y;
15    bool operator<(const node &a)const{
16        return x>a.x||(x==a.x&&y>a.y);
17    }

18}
node;
19
20/*typedef struct data{
21    double x,y;
22    bool cmp(data &a){
23        return x>a.x||(x==a.x&&y>a.y);
24    }
25}data;*/

26priority_queue<int,vector<int>,less<int> >LessIntq;//雖然是less但是是最大優(yōu)先
27priority_queue<int>SysIntq;//默認是less
28priority_queue<int,vector<int>,greater<int> >GreatIntq;
29priority_queue<node>Nodeq;
30//priority_queue<data,vector<data>,cmp>Cmpdata;
31
32
33int main()
34{
35    int i,temp;
36    for(i=1;i<=5;i++){
37        scanf("%d",&temp);
38        LessIntq.push(temp);
39        SysIntq.push(temp);
40        GreatIntq.push(temp);
41    }

42    cout<<"LessIntq::";
43    print(LessIntq);
44    cout<<"SysIntq::";
45    print(SysIntq);
46    cout<<"GreatIntq::";
47    print(GreatIntq);
48    cout<<"******************"<<endl;
49
50    node ntemp;
51    for(i=1;i<=5;i++){
52        scanf("%d%d",&ntemp.x,&ntemp.y);
53        Nodeq.push(ntemp);
54    }

55    cout<<"Nodeq::"<<endl;
56    for(i=0;i<5;i++){
57        cout<<Nodeq.top().x<<"::"<<Nodeq.top().y<<endl;
58        Nodeq.pop();
59    }

60
61/*    data dtemp;
62    for(i=1;i<=5;i++){
63        scanf("%lf%lf",&dtemp.x,&dtemp.y);
64        Cmpdata.push(dtemp);
65    }
66    cout<<"Cmpdata::";
67    for(i=0;i<5;i++){
68        cout<<Cmpdata.top().x<<"::"<<Cmpdata.top().y<<endl;
69        Cmpdata.pop();
70    }*/

71    return 0;
72}

73/****************************************
742 5 1 3 7
75LessIntq::7 5 3 2 1
76SysIntq::7 5 3 2 1
77GreatIntq::1 2 3 5 7
78******************
791 2
805 6
812 3
822 10
837 7
84Nodeq::
851::2
862::3
872::10
885::6
897::7
90Press any key to continue
91*************************************/
posted @ 2008-08-29 11:31 Torres 閱讀(346) | 評論 (0)編輯 收藏

     摘要: 在模板參數,傳遞類名,在 ( 離散 ) 函數參數中,使用函數名 ( myStruct(); 或 myFunc ) 內置 <functional> : greater <T>, less<T>, greater_equal<T>, less_equal<T>, equal_to<T>, not_equal_to<T&g...  閱讀全文
posted @ 2008-08-28 21:31 Torres 閱讀(224) | 評論 (0)編輯 收藏

     摘要:   1#include<iostream>  2#include<string>  3#include<algorithm>  4using namespace std;  5int main()  6{ ...  閱讀全文
posted @ 2008-08-19 17:16 Torres 閱讀(282) | 評論 (0)編輯 收藏

C++ Queues

The C++ Queue is a container adapter that gives the programmer a FIFO (first-in, first-out) data structure.

Display all entries for C++ Queues on one page, or view entries individually:

Queue constructor construct a new queue
back returns a reference to last element of a queue
empty true if the queue has no elements
front returns a reference to the first element of a queue
pop removes the first element of a queue
push adds an element to the end of the queue
size returns the number of items in the queue
 1#include<iostream>
 2#include<queue>
 3#include<algorithm>
 4using namespace std;
 5int main()
 6{
 7    //隊列,first_in ,first_out,不提供迭代器,不提供走訪功能
 8    int i;
 9    queue<int>q;
10    for(i=0;i<5;i++)q.push(i);
11    while(q.size()){
12        cout<<q.front();
13        q.pop();
14    }

15    return 0;
16}

17
posted @ 2008-08-18 11:36 Torres 閱讀(12106) | 評論 (0)編輯 收藏

C++ Double-ended Queues

Double-ended queues are like vectors, except that they allow fast insertions and deletions at the beginning (as well as the end) of the container.

Display all entries for C++ Double-ended Queues on one page, or view entries individually:

Container constructors create dequeues and initialize them with some data
Container operators compare, assign, and access elements of a dequeue
assign assign elements to a dequeue
at returns an element at a specific location
back returns a reference to last element of a dequeue
begin returns an iterator to the beginning of the dequeue
clear removes all elements from the dequeue
empty true if the dequeue has no elements
end returns an iterator just past the last element of a dequeue
erase removes elements from a dequeue
front returns a reference to the first element of a dequeue
insert inserts elements into the dequeue
max_size returns the maximum number of elements that the dequeue can hold
pop_back removes the last element of a dequeue
pop_front removes the first element of the dequeue
push_back add an element to the end of the dequeue
push_front add an element to the front of the dequeue
rbegin returns a reverse_iterator to the end of the dequeue
rend returns a reverse_iterator to the beginning of the dequeue
resize change the size of the dequeue
size returns the number of items in the dequeue
swap swap the contents of this dequeue with another

在我看來,deque就是一個雙端的array,和vector是一摸一樣的,雖然內部機制不一樣
 1/*
 2  Name: C++ DEQUE   
 3  Copyright: 
 4  Author: Torres
 5  Date: 18-08-08 10:55
 6  Description: STL DEQUE 學習筆記 
 7*/

 8#include<deque>
 9#include<iostream>
10#include<algorithm>
11using namespace std;
12#define showpass cout<<"pass"<<endl
13typedef struct point{
14    double x,y;
15    point(double a=0,double b=0){
16        x=a;
17        y=b;
18    }

19}
point;
20ostream operator<<(ostream out,point a)
21{
22    return out<<a.x<<" "<<a.y<<endl;
23}

24
25void print(point a)
26{
27    cout<<a;
28}

29int main()
30{
31    //deque與vector很相似只不過是兩端都可以存取的vector
32    deque<point>cp,cp1(10);
33    int i;
34    for(i=0;i<5;i++){
35        point temp(i,i+1);
36        cp.push_back (temp);
37    }

38    
39    for(i=0;i<5;i++){
40        cp1[i].x=i;
41        cp1[i].y=i+1;
42    }

43    //取地址符號[]必須在容器已經開辟空間后才能用,push函數開辟了新空間
44    for_each(cp.begin(),cp.end(),print);
45    cout<<endl;
46    for_each(cp1.begin(),cp1.end()-5,print);
47    cout<<endl;
48    
49    //erase刪除函數
50    cp.erase(cp.begin()+1);
51    for_each(cp.begin(),cp.end(),print);
52    cout<<endl;
53    cp1.erase(cp1.begin(),cp1.begin()+3);
54    for_each(cp1.begin(),cp1.end()-5,print);
55    cout<<endl;
56
57    cout<<cp.front()<<cp.back()<<endl; 
58
59
60    return 0;
61}

posted @ 2008-08-18 11:02 Torres 閱讀(664) | 評論 (0)編輯 收藏

先看函數:
C++ Lists

Lists are sequences of elements stored in a linked list. Compared to vectors, they allow fast insertions and deletions, but slower random access.

Display all entries for C++ Lists on one page, or view entries individually:

List constructors create lists and initialize them with some data
List operators assign and compare lists
assign assign elements to a list
back returns a reference to last element of a list
begin returns an iterator to the beginning of the list
clear removes all elements from the list
empty true if the list has no elements
end returns an iterator just past the last element of a list
erase removes elements from a list
front returns a reference to the first element of a list
insert inserts elements into the list
max_size returns the maximum number of elements that the list can hold
merge merge two lists
pop_back removes the last element of a list
pop_front removes the first element of the list
push_back add an element to the end of the list
push_front add an element to the front of the list
rbegin returns a reverse_iterator to the end of the list
remove removes elements from a list
remove_if removes elements conditionally
rend returns a reverse_iterator to the beginning of the list
resize change the size of the list
reverse reverse the list
size returns the number of items in the list
sort sorts a list into ascending order
splice merge two lists in constant time
swap swap the contents of this list with another
unique removes consecutive duplicate elements

要注意的是list不提隨機的迭代器,迭代器是個雙向的,非連續(xù)存儲,而且是個環(huán)狀鏈表在尾端是個未初始化節(jié)點
空判斷:begin==end;
clear  remove  unique(把相同元素移出,留一個先sort)  insert(插入兩種方式)
只能使用成員函數 sort,不能使用 算法 sort(他只接受random iterator)

 1/*
 2  Name: C++ STL LIST    
 3  Copyright: 
 4  Author: Torres
 5  Date: 17-08-08 23:28
 6  Description: LIST 學習筆記 
 7*/

 8#include<iostream>
 9#include<list>
10#include<vector>
11#include<algorithm>
12using namespace std;
13typedef struct node{
14    double x,y;
15    node (double a=0,double b=0){
16        x=a;
17        y=b;
18    }

19}
node;
20void print(int a){printf("%d ",a);return;}
21
22ostream operator <<(ostream out,node a)
23{
24    return out<<a.x<<" "<<a.y<<endl;
25}

26int main()
27{
28    int i,j;
29
30    list<node>nlist;
31    list<int>intlist,intlist1;
32    
33    vector<int>intv1,intv2;
34    intv1.assign(5,7);
35    intv2.assign(intv1.begin()+1,intv1.end()-1);
36    for_each(intv2.begin()+1,intv2.end(),print);
37    cout<<endl;
38
39    //assign的用法,有兩種,發(fā)現(xiàn)list的iterator不能夠相加而vector可以
40    intlist.assign(5,7);
41    intlist1.assign(intlist.begin(),intlist.end());
42    for_each(intlist.begin(),intlist.end(),print);
43    printf("\n");
44    for_each(intlist1.begin(),intlist1.end(),print);
45    printf("\n");
46    
47    //size的用法,表示實際數據的大小
48    cout<<intlist.size()<<endl;
49    //list沒有容量capacity函數
50
51    //因為list是一個雙端鏈表,不支持隨機存取,他的存取必須用iterator來進行
52    //而vector,deque,等容器是支持的。
53    list<int>::iterator it1;
54    for(it1=intlist1.begin();it1!=intlist1.end();it1++)
55        cout<<*it1<<" ";
56    cout<<endl;
57
58    const node cnode(1.0,2.0);
59    cout<<cnode<<endl;
60
61    nlist.assign(5,cnode);
62    list<node>::iterator it2;
63    for(it2=nlist.begin();it2!=nlist.end();it2++)
64        cout<<*it2;
65    return 0;
66}

67

posted @ 2008-08-17 23:30 Torres 閱讀(673) | 評論 (0)編輯 收藏

菜菜的學習了一下STL的vector,做一下筆記感覺這個網站講得通俗易懂http://www.cppreference.com/cppvector/index.html 寫了一下測試code(待續(xù))

C++ Vectors

Vectors contain contiguous elements stored as an array. Accessing members of a vector or appending elements can be done in constant time, whereas locating a specific value or inserting elements into the vector takes linear time.

Display all entries for C++ Vectors on one page, or view entries individually:

Vector constructors create vectors and initialize them with some data
Vector operators compare, assign, and access elements of a vector
assign assign elements to a vector
at returns an element at a specific location
back returns a reference to last element of a vector
begin returns an iterator to the beginning of the vector
capacity returns the number of elements that the vector can hold
clear removes all elements from the vector
empty true if the vector has no elements
end returns an iterator just past the last element of a vector
erase removes elements from a vector
front returns a reference to the first element of a vector
insert inserts elements into the vector
max_size returns the maximum number of elements that the vector can hold
pop_back removes the last element of a vector
push_back add an element to the end of the vector
rbegin returns a reverse_iterator to the end of the vector
rend returns a reverse_iterator to the beginning of the vector
reserve sets the minimum capacity of the vector
resize change the size of the vector
size returns the number of items in the vector
swap swap the contents of this vector with another

 1#include<vector>
 2#include<iostream>
 3#include<algorithm>
 4using namespace std;
 5void print(int a){cout<<a<<" ";}
 6int main()
 7{
 8    vector<int>v,v1;
 9    vector<int>::iterator iv1,iv2;
10    vector<int>v2;
11    v2.reserve(10);    
12    v.assign(10,2);
13    cout<<v2.capacity()<<endl;//capacity容量輸出為10
14    cout<<v2.size()<<endl;//大小輸出為1
15    int i;
16    for(i=0;i<7;i++)v2.push_back(i);
17    for_each(v2.begin(),v2.end(),print);
18    cout<<endl;
19    for(iv1=v2.begin();iv1!=v2.end();iv1++)
20        if(*iv1==3)break;
21    if(iv1!=v2.end())v2.insert(iv1,99);
22    for_each(v2.begin(),v2.end(),print);
23    cout<<endl;
24    if(iv1!=v2.end())v2.insert(iv1,5,99);
25    for_each(v2.begin(),v2.end(),print);
26    cout<<endl;
27    if(iv1!=v2.end())v2.insert(iv1,v.begin(),v.end());
28    for_each(v2.begin(),v2.end(),print);
29    cout<<endl;
30    cout<<v2.size()<<endl;
31    v2.erase(v2.begin());
32    cout<<v2.size()<<endl;
33    v2.erase(v2.begin(),v2.end());
34    for_each(v2.begin(),v2.end(),print);
35    iv1=v.begin();iv2=v.end();
36    cout<<v.begin()<<endl;
37    cout<<v.end()<<endl;
38    cout<<iv1<<endl;
39    cout<<iv2<<endl;
40//    for(i=0;i<15;i++)cout<<v[i]<<" ";
41//    cout<<endl;
42//    for(i=0;i<15;i++)cout<<v.at(i)<<" ";//at()函數更加安全;
43//    cout<<endl;
44    for_each(v.begin(),v.end(),print);
45    cout<<endl;
46//    v1.assign(v.begin(),v.end());
47//    v1.assign(iv1+2,iv2-2);
48//    for(i=0;i<10;i++)cout<<v1[i]<<' ';
49//    cout<<endl;
50    for(i=0;i<10;i++)v1.push_back(i);
51    for_each(v1.begin()+1,v1.end()-2,print);//輸出begin開始指向的數據,直到end指向的前一個數據
52    for_each(v1.begin(),v1.end(),print);
53    cout<<endl;
54    cout<<v1.back()<<endl;
55    cout<<v1.front()<<endl;
56    cout<<v1.size()<<endl;
57    v.clear();
58    cout<<v.size()<<endl;
59    for_each(v.begin(),v.end(),print);//已經clear,begin==end,不會有任何結果。
60    return 0;
61}

62
63
64
65//試了一下結構體,感覺自己簡直太水了,努力學習中!
66
67#include<iostream>
68#include<vector>
69using namespace std;
70typedef struct node{
71    int x;
72    int y;
73}
node;
74ostream operator<<(ostream in,node a){
75    in<<a.x<<a.y<<endl;
76    return in;
77}

78int main()
79{
80    vector<node>v(10);
81    v[0].x=1;v[0].y=1;
82    vector<node>::iterator iv(v.begin());
83    cout<<v[0].x<<v[0].y<<endl;
84    cout<<*iv<<endl;
85    cout<<iv->x<<iv->y<<endl;
86    return 0;
87}
posted @ 2008-08-13 00:54 Torres 閱讀(174) | 評論 (0)編輯 收藏

一直想有一個blog,做做筆記,整理整理思路,基于這個思想,這個blog誕生了!以后就靠這個來祭奠生活了。
posted @ 2008-08-11 12:30 Torres 閱讀(187) | 評論 (1)編輯 收藏

僅列出標題
共7頁: 1 2 3 4 5 6 7 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲精品欧美极品| 欧美顶级少妇做爰| 午夜精品视频| 国产热re99久久6国产精品| 午夜在线一区二区| 久久成人精品| 亚洲欧洲一二三| 日韩亚洲欧美成人一区| 国产精品私拍pans大尺度在线 | 国产精品视频网址| 久久亚洲捆绑美女| 欧美成人精品福利| 羞羞答答国产精品www一本| 欧美一区亚洲| 夜夜精品视频| 欧美一区二区网站| 亚洲精品在线观看免费| 亚洲视频二区| 亚洲欧洲视频| 午夜激情综合网| 亚洲精品婷婷| 欧美在线视频观看| 亚洲图片在线观看| 久久午夜电影| 欧美一区二区三区久久精品茉莉花 | 亚洲精品乱码久久久久| 国产精品日韩欧美一区| 亚洲第一综合天堂另类专| 国产精品人人爽人人做我的可爱| 欧美a一区二区| 国产精品久久久久免费a∨大胸| 免费国产自线拍一欧美视频| 欧美午夜久久久| 欧美成在线观看| 国产欧美日韩| 一级成人国产| 日韩网站在线观看| 久久久久久伊人| 欧美诱惑福利视频| 欧美视频一区二区三区四区| 欧美大片免费观看| 韩曰欧美视频免费观看| 亚洲一二区在线| 夜夜爽夜夜爽精品视频| 久热精品视频在线观看| 久久成人精品电影| 国产精品亚洲综合色区韩国| 亚洲伦理中文字幕| 亚洲人成网站影音先锋播放| 久久久噜噜噜久噜久久| 欧美一区二区三区在线观看| 国产精品初高中精品久久| 亚洲三级视频| 一区二区三区蜜桃网| 欧美成人一区二免费视频软件| 久久在线播放| 精品成人久久| 久久久五月婷婷| 美女图片一区二区| 禁断一区二区三区在线| 久久久精彩视频| 免费黄网站欧美| 亚洲国产日韩在线| 免费欧美在线| 亚洲激情二区| 亚洲视屏在线播放| 欧美视频二区| 午夜欧美精品| 久久综合狠狠综合久久激情| 永久域名在线精品| 蜜臀va亚洲va欧美va天堂| 亚洲电影视频在线| 一区二区三区精品国产| 国产精品免费看| 欧美主播一区二区三区| 久久综合国产精品台湾中文娱乐网| 激情欧美一区二区| 麻豆精品精品国产自在97香蕉| 欧美国产日韩在线| 亚洲视频观看| 国产亚洲a∨片在线观看| 久久免费少妇高潮久久精品99| 欧美电影美腿模特1979在线看 | 欧美性做爰毛片| 欧美一级淫片播放口| 免费欧美日韩国产三级电影| 亚洲三级影院| 国产精品一区二区久久久久| 久久精品一区二区三区不卡| 欧美激情aaaa| 午夜激情综合网| 亚洲国产精品免费| 国产精品国产三级国产| 久久久久久久综合| 亚洲日本va在线观看| 久久国产精品色婷婷| 91久久久久久久久| 国产视频一区在线观看| 欧美不卡视频| 亚洲欧美日韩成人| 亚洲九九九在线观看| 久久久久久久一区二区三区| 在线亚洲免费视频| 影音先锋欧美精品| 国产精品乱子久久久久| 欧美好吊妞视频| 久久成人18免费网站| 一区二区三区欧美激情| 欧美激情欧美狂野欧美精品| 欧美亚洲视频在线看网址| 91久久香蕉国产日韩欧美9色 | 女人天堂亚洲aⅴ在线观看| 亚洲一级一区| 日韩一区二区福利| 欧美国产成人在线| 久久婷婷久久| 久久国产成人| 亚洲欧洲av一区二区三区久久| 亚洲美女色禁图| 亚洲国产毛片完整版 | 亚洲国产高清高潮精品美女| 国产女主播一区二区| 欧美视频四区| 欧美日韩综合在线免费观看| 欧美成人综合在线| 久久精品国产亚洲高清剧情介绍| 亚洲网站在线观看| 99视频一区二区| 亚洲伦理中文字幕| 亚洲人成在线观看网站高清| 欧美激情一区二区三区蜜桃视频| 老司机67194精品线观看| 久久精品人人爽| 久久精品理论片| 久久美女性网| 免费久久99精品国产| 久久视频在线看| 毛片基地黄久久久久久天堂| 久久影院午夜论| 蜜桃精品久久久久久久免费影院| 久久久久久一区二区三区| 久久视频这里只有精品| 久久蜜臀精品av| 欧美成人精品1314www| 欧美大片第1页| 91久久国产综合久久91精品网站| 亚洲高清色综合| 99日韩精品| 亚洲男人的天堂在线aⅴ视频| 午夜精品剧场| 久久免费99精品久久久久久| 久久中文字幕一区| 欧美精品日韩| 国产精品久久久久毛片软件| 国产亚洲欧美日韩精品| 又紧又大又爽精品一区二区| 亚洲人人精品| 亚洲资源av| 久久伊人免费视频| 亚洲国产精品一区二区三区| 99热精品在线观看| 欧美一区二区三区在线观看| 美日韩精品免费观看视频| 欧美美女喷水视频| 国产麻豆9l精品三级站| 欲色影视综合吧| 亚洲调教视频在线观看| 久久精品国产77777蜜臀| 欧美国产在线电影| 亚洲一区二区在线视频| 久久免费精品视频| 欧美三级电影精品| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲美女视频在线免费观看| 先锋a资源在线看亚洲| 免费在线看成人av| 亚洲色图制服丝袜| 美日韩精品免费| 国产精品主播| av成人免费在线| 久久综合综合久久综合| 一区二区三区高清视频在线观看 | 99综合电影在线视频| 久久久精品日韩欧美| 欧美午夜剧场| 亚洲国产三级在线| 久久精品观看| 亚洲毛片在线观看| 久久午夜国产精品| 国产亚洲精品高潮| 亚洲一区二区三区免费视频| 蜜桃久久av一区| 香蕉久久一区二区不卡无毒影院 | 国产精品区免费视频| 亚洲精品国产系列| 久久久免费精品视频| 亚洲午夜精品久久久久久app| 欧美1区2区| 亚洲国产精品va在线看黑人动漫| 新片速递亚洲合集欧美合集|