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

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>
            国产日本欧美一区二区| 欧美a级一区二区| 国产精品久久一卡二卡| 亚洲一二三区精品| 亚洲免费伊人电影在线观看av| 欧美色播在线播放| 午夜欧美不卡精品aaaaa| 性感少妇一区| 亚洲国产天堂久久综合网| 欧美激情视频一区二区三区在线播放| 老色鬼久久亚洲一区二区| 亚洲精品乱码视频| 亚洲欧美日本国产有色| 一区一区视频| 亚洲春色另类小说| 欧美视频在线免费| 久久伊人亚洲| 国产精品啊v在线| 久久露脸国产精品| 欧美日韩免费高清| 久久久99国产精品免费| 欧美成年人网站| 欧美在线黄色| 欧美精品久久久久a| 久久精品人人做人人爽| 欧美久久影院| 久久噜噜亚洲综合| 国产精品成人免费精品自在线观看| 久久久久久久999| 欧美日韩久久| 欧美激情一级片一区二区| 国产精品萝li| 亚洲精品永久免费| 一区精品在线| 午夜精品偷拍| 亚洲制服av| 中文亚洲欧美| 欧美国产欧美亚洲国产日韩mv天天看完整 | 欧美精品大片| 久久久国产精品一区二区三区| 欧美日韩大陆在线| 欧美国产精品久久| 国语自产精品视频在线看| 一本色道久久综合亚洲精品婷婷| 亚洲高清二区| 久久久天天操| 久久中文精品| 狠狠狠色丁香婷婷综合激情| 中文精品一区二区三区 | 免费成人av在线| 国产日韩精品一区二区浪潮av| 日韩一级在线观看| 日韩天堂在线观看| 欧美承认网站| 亚洲高清在线观看| 亚洲国产高清自拍| 老司机成人网| 亚洲成人在线视频播放 | 狂野欧美激情性xxxx| 久久视频在线看| 国产一区亚洲| 欧美在线视频导航| 久久精品视频播放| 国产亚洲欧洲997久久综合| 亚洲一区在线看| 性欧美xxxx视频在线观看| 欧美午夜精品理论片a级大开眼界| 亚洲精品视频免费| 国产精品99久久久久久久久久久久| 欧美搞黄网站| 亚洲美女尤物影院| 亚洲欧美日韩区| 国产精自产拍久久久久久| 亚洲一区二区在线免费观看| 亚洲免费综合| 国产曰批免费观看久久久| 久久久精品一区| 欧美第十八页| 一区二区日韩伦理片| 国产精品久久久久一区| 亚洲一区网站| 欧美搞黄网站| 亚洲天堂黄色| 狠狠久久五月精品中文字幕| 老司机一区二区三区| 日韩一级片网址| 久久精品视频播放| 亚洲精品久久在线| 欧美午夜精品久久久久久久| 性一交一乱一区二区洋洋av| 欧美成熟视频| 亚洲欧美在线一区二区| 国产综合精品一区| 欧美精品色一区二区三区| 亚洲免费影视| 亚洲欧洲精品一区二区| 午夜精品在线视频| 亚洲啪啪91| 国产美女在线精品免费观看| 另类欧美日韩国产在线| 亚洲一区二区少妇| 欧美高清视频在线观看| 亚洲女人天堂av| 亚洲三级免费观看| 国产真实乱偷精品视频免| 欧美精品一区二区三区一线天视频 | 欧美一区二区三区四区高清| 亚洲国产女人aaa毛片在线| 国产精品激情电影| 欧美成人久久| 久久精品免费| 亚洲自拍偷拍福利| 亚洲精品美女在线| 免费在线欧美黄色| 久久成人免费| 亚洲欧美日韩一区二区三区在线观看 | 女同一区二区| 久久久夜夜夜| 欧美在线观看视频| 亚洲视频你懂的| 亚洲免费观看高清完整版在线观看熊| 国产日韩专区| 国产精品爽黄69| 欧美日韩中国免费专区在线看| 久久亚洲综合色一区二区三区| 午夜激情亚洲| 亚洲欧美在线看| 亚洲网友自拍| 亚洲少妇诱惑| 一区二区三区四区五区视频| 亚洲福利av| 亚洲国产日韩欧美| 欧美激情精品久久久久| 卡一卡二国产精品| 久久女同精品一区二区| 久久精品二区三区| 久久久99国产精品免费| 久久久国产精品一区二区中文| 亚洲欧美一区二区视频| 亚洲免费视频网站| 欧美亚洲三区| 久久精品国产69国产精品亚洲| 欧美一区二区三区在线| 欧美一区二区三区免费视频| 亚洲欧美国产精品专区久久| 亚洲免费在线电影| 欧美有码在线观看视频| 久久久在线视频| 欧美成人精品h版在线观看| 免费日韩一区二区| 欧美激情精品久久久六区热门| 亚洲福利电影| 亚洲作爱视频| 午夜精品久久久久| 久久久www成人免费精品| 另类春色校园亚洲| 欧美日韩国产一区精品一区 | 18成人免费观看视频| 亚洲黄色天堂| 亚洲一区黄色| 久久久久国产精品www| 美女黄毛**国产精品啪啪| 亚洲高清视频在线| 亚洲图片自拍偷拍| 久久婷婷蜜乳一本欲蜜臀| 欧美另类在线观看| 国产欧美精品日韩区二区麻豆天美| 国产一区二区三区黄| 亚洲精品中文字幕女同| 亚洲欧美国内爽妇网| 麻豆免费精品视频| 99精品欧美一区| 久久精品99无色码中文字幕| 欧美精品一区二区三区久久久竹菊| 国产精品v亚洲精品v日韩精品| 好吊成人免视频| 亚洲视频第一页| 免费高清在线视频一区·| 99国产精品久久久| 久久这里有精品15一区二区三区| 欧美日韩精品一本二本三本| 黄色小说综合网站| 亚洲一级免费视频| 欧美二区在线播放| 校园激情久久| 欧美视频一区二区三区| 影音先锋国产精品| 欧美一区二区三区久久精品茉莉花 | 99视频一区二区| 久久综合一区二区三区| 国产精品欧美日韩一区| 亚洲精品视频在线播放| 久久精品国产99精品国产亚洲性色 | 亚洲网站在线观看| 欧美 日韩 国产精品免费观看| 亚洲综合好骚| 国产精品国产精品国产专区不蜜| 亚洲第一精品福利| 久久久久久亚洲综合影院红桃 | 欧美激情精品久久久久久|