亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? algorithms in c++, parts 1-4 (fundamental algorithms, data structures, sorting, searching) code.txt

?? Algorithms in C++, Parts 1-4 (Fundamental Algorithms, Data Structures, Sorting, Searching) code
?? TXT
?? 第 1 頁 / 共 5 頁
字號:
        This file contains the code from "Algorithms in C++, Third Edition,        Parts 1-4," by Robert Sedgewick, and is covered under the copyright        and warranty notices in that book. Permission is granted for this        code to be used for educational purposes in association with the text,        and for other uses not covered by copyright laws, provided that        the following notice is included with the code:                "This code is from "Algorithms in C++, Third Edition,"                by Robert Sedgewick, Addison-Wesley, 1999."        Commercial uses of this code require the explicit written        permission of the publisher. Send your request for permission,        stating clearly what code you would like to use, and in what        specific way, to: aw.cse@aw.com----------CHAPTER 1. Introduction-----#include <iostream.h>static const int N = 10000;int main()  { int i, p, q, id[N];    for (i = 0; i < N; i++) id[i] = i;    while (cin >> p >> q)      { int t = id[p];        if (t == id[q]) continue;        for (i = 0; i < N; i++)          if (id[i] == t) id[i] = id[q];        cout << " " << p << " " << q << endl;      } }-----    for (i = p; i != id[i]; i = id[i]) ;    for (j = q; j != id[j]; j = id[j]) ;    if (i == j) continue;    id[i] = j;    cout << " " << p << " " << q << endl;    -----#include <iostream.h>static const int N = 10000;int main()  { int i, j, p, q, id[N], sz[N];    for (i = 0; i < N; i++)       { id[i] = i; sz[i] = 1; }    while (cin >> p >> q)      {         for (i = p; i != id[i]; i = id[i]) ;        for (j = q; j != id[j]; j = id[j]) ;        if (i == j) continue;        if (sz[i] < sz[j])             { id[i] = j; sz[j] += sz[i]; }        else { id[j] = i; sz[i] += sz[j]; }        cout << " " << p << " " << q << endl;      } }-----    for (i = p; i != id[i]; i = id[i])       id[i] = id[id[i]];     for (j = q; j != id[j]; j = id[j])       id[j] = id[id[j]];     ----------CHAPTER 2. Principles of Algorithm Analysis-----int search(int a[], int v, int l, int r)  {     for (int i = l; i <= r; i++)      if (v == a[i]) return i;    return -1;  }-----int search(int a[], int v, int l, int r)  {     while (r >= l)      { int m = (l+r)/2;        if (v == a[m]) return m;        if (v < a[m]) r = m-1; else l = m+1;      }    return -1;  }----------CHAPTER 3. Elementary Data Structures-----#include <iostream.h>int lg(int);int main()  {     for (int N = 1000; N <= 1000000000; N *= 10)      cout << lg(N) << " " << N << endl;   }int lg(int N)  {    for (int i = 0; N > 0; i++, N /= 2) ;    return i;      }-----#include <iostream.h>#include <stdlib.h>#include <math.h>typedef int Number;Number randNum()  { return rand(); }int main(int argc, char *argv[])  { int N = atoi(argv[1]);    float m1 = 0.0, m2 = 0.0;    for (int i = 0; i < N; i++)      {        Number x = randNum();        m1 += ((float) x)/N;         m2 += ((float) x*x)/N;      }    cout << "     Avg.: " << m1 << endl;    cout << "Std. dev.: " << sqrt(m2-m1*m1) << endl;  }-----struct point { float x; float y; };float distance(point, point);-----#include <math.h>#include "Point.h"float distance(point a, point b)  { float dx = a.x - b.x, dy = a.y - b.y;    return sqrt(dx*dx + dy*dy);  }-----#include <iostream.h>static const int N = 1000;int main()  { int i, a[N];    for (i = 2; i < N; i++) a[i] = 1;    for (i = 2; i < N; i++)      if (a[i])        for (int j = i; j*i < N; j++) a[i*j] = 0;    for (i = 2; i < N; i++)      if (a[i]) cout << " " << i;    cout << endl;  }-----int main(int argc, char *argv[])  { int i, N = atoi(argv[1]);    int *a = new int[N];    if (a == 0)       { cout << "out of memory" << endl; return 0; }    ...-----#include <iostream.h>#include <stdlib.h>int heads()  { return rand() < RAND_MAX/2; }int main(int argc, char *argv[])  { int i, j, cnt;    int N = atoi(argv[1]), M = atoi(argv[2]);    int *f = new int[N+1];    for (j = 0; j <= N; j++) f[j] = 0;    for (i = 0; i < M; i++, f[cnt]++)      for (cnt = 0, j = 0; j <= N; j++)         if (heads()) cnt++;    for (j = 0; j <= N; j++)       {        if (f[j] == 0) cout << ".";        for (i = 0; i < f[j]; i+=10) cout << "*";        cout << endl;      } }-----#include <math.h>#include <iostream.h>#include <stdlib.h>#include "Point.h"float randFloat()  { return 1.0*rand()/RAND_MAX; }int main(int argc, char *argv[]) { float d = atof(argv[2]);    int i, cnt = 0, N = atoi(argv[1]);   point *a = new point[N];   for (i = 0; i < N; i++)     { a[i].x = randFloat(); a[i].y = randFloat(); }   for (i = 0; i < N; i++)     for (int j = i+1; j < N; j++)       if (distance(a[i], a[j]) < d) cnt++;    cout << cnt << " pairs within " << d << endl; }-----#include <iostream.h>#include <stdlib.h>struct node   { int item; node* next;     node(int x, node* t)       { item = x; next = t; }   };typedef node *link;int main(int argc, char *argv[])  { int i, N = atoi(argv[1]), M = atoi(argv[2]);     link t = new node(1, 0); t->next = t;    link x = t;    for (i = 2; i <= N; i++)      x = (x->next = new node(i, t));    while (x != x->next)      {        for (i = 1; i < M; i++) x = x->next;        x->next = x->next->next;       }    cout << x->item << endl;  }-----link reverse(link x)  { link t, y = x, r = 0;    while (y != 0)      { t = y->next; y->next = r; r = y; y = t; }        return r;  }-----    node heada(0, 0); link a = &heada, t = a;     for (int i = 0; i < N; i++)      t = (t->next = new node(rand() % 1000, 0));     node headb(0, 0); link u, x, b = &headb;    for (t = a->next; t != 0; t = u)      {        u = t->next;        for (x = b; x->next != 0; x = x->next)          if (x->next->item > t->item) break;        t->next = x->next; x->next = t;       }-----typedef int Item;struct node { Item item; node *next; };typedef node *link;typedef link Node;void construct(int);Node newNode(int);void deleteNode(Node);void insert(Node, Node);Node remove(Node);Node next(Node);Item item(Node);-----#include <iostream.h>#include <stdlib.h>#include "list.h"int main(int argc, char *argv[])  { int i, N = atoi(argv[1]), M = atoi(argv[2]);     Node t, x;    construct(N);     for (i = 2, x = newNode(1); i <= N; i++)      { t = newNode(i); insert(x, t); x = t; }    while (x != next(x))      {        for (i = 1; i < M; i++) x = next(x);        deleteNode(remove(x));       }    cout << item(x) << endl;    return 0;  }-----#include <stdlib.h>#include "list.h"link freelist;void construct(int N)  {     freelist = new node[N+1];    for (int i = 0; i < N; i++)      freelist[i].next = &freelist[i+1];    freelist[N].next = 0;  }    link newNode(int i)  { link x = remove(freelist);     x->item = i; x->next = x;    return x;  }void deleteNode(link x)  { insert(freelist, x); }void insert(link x, link t)  { t->next = x->next; x->next = t; }link remove(link x)  { link t = x->next; x->next = t->next; return t; }link next(link x)  { return x->next; }Item item(link x)  { return x->item; }-----#include <iostream.h>#include <string.h>static const int N = 10000;int main(int argc, char *argv[])  { int i; char t;     char a[N], *p = argv[1];    for (i = 0; i < N-1; a[i] = t, i++)      if (!cin.get(t)) break;    a[i] = 0;    for (i = 0; a[i] != 0; i++)      { int j;        for (j = 0; p[j] != 0; j++)          if (a[i+j] != p[j]) break;        if (p[j] == 0) cout << i << " ";      }            cout << endl;  }-----int **malloc2d(int r, int c)  { int **t = new int*[r];    for (int i = 0; i < r; i++)      t[i] = new int[c];    return t;  }-----#include <iostream.h>#include <stdlib.h>#include <string.h>int compare(const void *i, const void *j)  { return strcmp(*(char **)i, *(char **)j); }int main()  { const int Nmax = 1000;    const int Mmax = 10000;    char* a[Nmax]; int N;    char buf[Mmax]; int M = 0;    for (N = 0; N < Nmax; N++)      {        a[N] = &buf[M];        if (!(cin >> a[N])) break;        M += strlen(a[N])+1;      }    qsort(a, N, sizeof(char*), compare);    for (int i = 0; i < N; i++)       cout << a[i] << endl;  }-----#include <iostream.h>int main()  { int i, j, adj[V][V];    for (i = 0; i < V; i++)      for (j = 0; j < V; j++)         adj[i][j] = 0;    for (i = 0; i < V; i++) adj[i][i] = 1;    while (cin >> i >> j)      { adj[i][j] = 1; adj[j][i] = 1; }  }-----#include <iostream.h>struct node   { int v; node* next;     node(int x, node* t)       { v = x; next = t; }   };typedef node *link;int main()  { int i, j; link adj[V];    for (i = 0; i < V; i++) adj[i] = 0;    while (cin >> i >> j)      {         adj[j] = new node(i, adj[j]);        adj[i] = new node(j, adj[i]);      }  }-----#include <math.h>#include <iostream.h>#include <stdlib.h>#include "Point.h"struct node   { point p; node *next;     node(point pt, node* t) { p = pt; next = t; } };typedef node *link;static link **grid; static int G, cnt = 0; static float d;void gridinsert(float x, float y)  { int X = x*G+1; int Y = y*G+1;    point p; p.x = x; p.y = y;    link s, t = new node(p, grid[X][Y]);    for (int i = X-1; i <= X+1; i++)      for (int j = Y-1; j <= Y+1; j++)        for (s = grid[i][j]; s != 0; s = s->next)          if (distance(s->p, t->p) < d) cnt++;     grid[X][Y] = t;  }int main(int argc, char *argv[]) { int i, N = atoi(argv[1]);   d = atof(argv[2]); G = 1/d;   grid = malloc2d(G+2, G+2);   for (i = 0; i < G+2; i++)     for (int j = 0; j < G+2; j++)       grid[i][j] = 0;   for (i = 0; i < N; i++)     gridinsert(randFloat(), randFloat());   cout << cnt << " pairs within " << d << endl; }---------------CHAPTER 4. Abstract Data Types-----#include <math.h>class POINT  {    private:      float x, y;    public:      POINT()        { x = 1.0*rand()/RAND_MAX;          y = 1.0*rand()/RAND_MAX; }      float distance(POINT a)        { float dx = x-a.x, dy = y-a.y;          return sqrt(dx*dx + dy*dy); }  };-----#include <iostream.h>#include <stdlib.h>#include "POINT.cxx"int main(int argc, char *argv[]) { float d = atof(argv[2]);    int i, cnt = 0, N = atoi(argv[1]);   POINT *a = new POINT[N];   for (i = 0; i < N; i++)     for (int j = i+1; j < N; j++)       if (a[i].distance(a[j]) < d) cnt++;    cout << cnt << " pairs within " << d << endl; }-----class POINT  {    private:      // Implementation-dependent code    public:      POINT();      float distance(POINT) const;  };-----template <class Item>class STACK   {    private:      // Implementation-dependent code    public:      STACK(int);      int empty() const;      void push(Item item);      Item pop();  };-----#include <iostream.h>#include <string.h>#include "STACK.cxx"int main(int argc, char *argv[])  { char *a = argv[1]; int N = strlen(a);    STACK<int> save(N);    for (int i = 0; i < N; i++)      {        if (a[i] == '+')           save.push(save.pop() + save.pop());        if (a[i] == '*')           save.push(save.pop() * save.pop());        if ((a[i] >= '0') && (a[i] <= '9'))           save.push(0);        while ((a[i] >= '0') && (a[i] <= '9'))           save.push(10*save.pop() + (a[i++]-'0'));       }    cout << save.pop() << endl;  }       -----#include <iostream.h>#include <string.h>#include "STACK.cxx"int main(int argc, char *argv[])  { char *a = argv[1]; int N = strlen(a);    STACK<char> ops(N);    for (int i = 0; i < N; i++)      {        if (a[i] == ')')          cout << ops.pop() << " ";        if ((a[i] == '+') || (a[i] == '*'))           ops.push(a[i]);        if ((a[i] >= '0') && (a[i] <= '9'))           cout << a[i] << " ";      }    cout << endl;  }       -----template <class Item>class STACK   {    private:      Item *s; int N;    public:      STACK(int maxN)        { s = new Item[maxN]; N = 0; }      int empty() const        { return N == 0; }      void push(Item item)        { s[N++] = item; }      Item pop()        { return s[--N]; }  };-----template <class Item>class STACK   {    private:      struct node         { Item item; node* next;           node(Item x, node* t)             { item = x; next = t; }         };      typedef node *link;      link head;    public:      STACK(int)        { head = 0; }      int empty() const        { return head == 0; }      void push(Item x)        { head = new node(x, head); }      Item pop()        { Item v = head->item; link t = head->next;          delete head; head = t; return v; }  };-----class UF   {    private:      // Implementation-dependent code    public:      UF(int);      int find(int, int);      void unite(int, int);  };-----#include <iostream.h>#include <stdlib.h>#include "UF.cxx"int main(int argc, char *argv[])  { int p, q, N = atoi(argv[1]);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合激情另类小说区| 国产喷白浆一区二区三区| 亚洲精品日韩一| 欧美裸体一区二区三区| 久久精品国产澳门| 国产精品伦理一区二区| 欧美日韩成人在线| 国产专区欧美精品| 国产精品亚洲专一区二区三区| 久久久久久亚洲综合影院红桃| 91久久国产最好的精华液| 久久精品国产99久久6| 免费精品视频在线| 一区二区三区欧美日| 久久久亚洲精华液精华液精华液| 精品国产1区二区| 在线播放日韩导航| 91麻豆精品国产91久久久久久久久| 成人av动漫网站| 国产老妇另类xxxxx| 国产成人在线影院| 国产在线看一区| 成人午夜短视频| 国产乱淫av一区二区三区| 懂色av一区二区夜夜嗨| 国产一区不卡精品| 三级欧美韩日大片在线看| 亚洲欧洲日本在线| 亚洲丝袜自拍清纯另类| 国产精品色噜噜| 亚洲成人先锋电影| 午夜精品视频在线观看| 亚洲国产视频在线| 亚洲无人区一区| 另类小说综合欧美亚洲| 欧美精品高清视频| 国产日韩在线不卡| 亚洲第一福利视频在线| 福利一区二区在线| 欧美一区二区视频免费观看| 欧美中文字幕一区| 欧美日韩成人在线一区| 久久精品一区二区三区不卡| 国产亚洲1区2区3区| 亚洲国产综合色| 大陆成人av片| 欧美草草影院在线视频| ww久久中文字幕| 国产精品网站导航| 麻豆国产精品一区二区三区| 蜜臀va亚洲va欧美va天堂| 91原创在线视频| 在线观看一区二区精品视频| 日韩一区二区免费电影| ww久久中文字幕| 日本强好片久久久久久aaa| 久久电影国产免费久久电影| 色婷婷久久99综合精品jk白丝| 色综合天天综合在线视频| 欧美熟乱第一页| 精品国产网站在线观看| 日韩精品电影在线| 欧美视频一区二| 亚洲码国产岛国毛片在线| 偷拍自拍另类欧美| 在线观看不卡视频| 一区二区三区**美女毛片| 成人免费的视频| 欧美激情一区二区三区在线| 亚洲欧美一区二区在线观看| 国产另类ts人妖一区二区| 精品日韩在线观看| 麻豆精品一区二区三区| 欧美一级黄色片| 欧美aa在线视频| 日韩免费电影一区| 亚洲另类在线制服丝袜| 91在线你懂得| 精品国产三级a在线观看| 麻豆成人91精品二区三区| 欧美一区二区福利在线| 日本在线不卡视频| 日韩精品一区二区三区视频播放| 日韩成人一级大片| 欧美大片在线观看一区| 国产一区福利在线| 久久久不卡网国产精品二区| 高清视频一区二区| 亚洲免费资源在线播放| 欧美日韩午夜在线视频| 中日韩av电影| 色综合天天综合给合国产| 一区二区三区电影在线播| 欧美日韩一区 二区 三区 久久精品| 午夜精品一区在线观看| 日韩精品一区二区三区视频在线观看 | 中文乱码免费一区二区| 高清在线观看日韩| 亚洲国产日韩av| 日韩美女视频在线| www.在线欧美| 久久久蜜桃精品| k8久久久一区二区三区| 亚洲午夜免费视频| 久久综合久久99| 一本久久综合亚洲鲁鲁五月天 | 久久久www免费人成精品| www.视频一区| 三级在线观看一区二区| 亚洲国产经典视频| 欧美乱妇一区二区三区不卡视频| 久久成人av少妇免费| 亚洲你懂的在线视频| 日韩欧美一区在线| 91论坛在线播放| 久久99精品国产.久久久久| 69av一区二区三区| 成人av网站在线| 丝袜诱惑制服诱惑色一区在线观看 | 韩日精品视频一区| 亚洲一区二区3| 欧美高清在线一区二区| 在线成人免费观看| 色婷婷狠狠综合| 床上的激情91.| 美国欧美日韩国产在线播放| 亚洲精品美腿丝袜| 中文字幕国产一区二区| 日韩欧美一级二级三级| 欧美三区在线观看| 91一区二区三区在线播放| 国产精品自产自拍| 欧美a级一区二区| 偷拍一区二区三区| 一片黄亚洲嫩模| 亚洲女人的天堂| 中文字幕在线观看不卡视频| 日韩免费视频一区| 91精品久久久久久蜜臀| 国产亚洲欧洲一区高清在线观看| 色久综合一二码| 99久久精品免费精品国产| 国产成人夜色高潮福利影视| 免费成人在线播放| 秋霞电影一区二区| 图片区小说区国产精品视频| 亚洲午夜国产一区99re久久| 国产精品无人区| 国产精品色一区二区三区| 国产女人18毛片水真多成人如厕| 精品久久国产老人久久综合| 日韩一区二区在线免费观看| 欧美精品乱码久久久久久按摩| 欧美日韩国产三级| 欧美日韩1区2区| 欧美一区二区三区小说| 777精品伊人久久久久大香线蕉| 在线精品视频一区二区| 欧美在线观看一二区| 欧美色图第一页| 欧美日韩国产免费| 日韩一区二区影院| 欧美精品一区二| 中文字幕不卡的av| 亚洲人成网站精品片在线观看 | 欧美日韩一级视频| 欧美日韩国产综合一区二区三区 | wwwwww.欧美系列| 日韩欧美国产综合在线一区二区三区| 欧美日韩不卡一区二区| 欧美大片在线观看| 中文字幕精品一区二区精品绿巨人 | 国产乱色国产精品免费视频| 国产福利91精品一区二区三区| 盗摄精品av一区二区三区| 99久久婷婷国产综合精品电影| 91国偷自产一区二区开放时间| 欧美日韩国产美| 国产午夜精品一区二区三区嫩草 | 波多野结衣一区二区三区| 91蜜桃在线免费视频| 欧美日韩在线播放| 精品福利av导航| 最新久久zyz资源站| 丝袜美腿亚洲一区| 国产成人亚洲综合a∨婷婷图片| av在线一区二区三区| 3751色影院一区二区三区| 久久免费电影网| 亚洲综合色婷婷| 激情综合网av| 欧美午夜一区二区| 国产色综合一区| 亚洲一区二区三区影院| 91精品国产日韩91久久久久久| 欧美xingq一区二区| 亚洲精品视频在线看| 激情综合网最新| 在线成人午夜影院| 国产精品福利一区|