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

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

?? 4.cpp

?? 《數據結構與程序設計》書本所有源代碼!!!!
?? CPP
字號:
/* Program extracts from Chapter 4 of   "Data Structures and Program Design in C++"   by Robert L. Kruse and Alexander J. Ryba   Copyright (C) 1999 by Prentice-Hall, Inc.  All rights reserved.   Extracts from this file may be used in the construction of other programs,   but this code will not compile or execute as given here. */// Section 4.1:int size, *dynamic_array, i;cout << "Enter an array size: " << flush;cin >> size;dynamic_array = new int[size];for (i = 0; i < size; i++) dynamic_array[i] = i;class Fraction{public:   int numerator;   int denominator;};Fraction *p;struct Node {//  data members   Node_entry entry;   Node *next;//  constructors   Node();   Node(Node_entry item, Node *add_on = NULL);};Node::Node(){   next = NULL;}Node::Node(Node_entry item, Node *add_on){   entry = item;   next = add_on;}Node first_node('a'); //  Node first_node stores data 'a'.Node *p0 = &first_node;  //  p0 points to first_Node.Node *p1 = new Node('b'); //  A second node storing 'b' is created.p0->next = p1;  //  The second Node is linked after first_node.Node *p2 = new Node('c', p0);  //  A third Node storing 'c' is created.    //  The third Node links back to the first node, *p0.p1->next = p2;  //  The third Node is linked after the second Node.Node *p0 = new Node('0');Node *p1 = p0->next = new Node('1');Node *p2 = p1->next = new Node('2', p1);// Section 4.2:class Stack {public:   Stack();   bool empty() const;   Error_code push(const Stack_entry &item);   Error_code pop();   Error_code top(Stack_entry &item) const;protected:   Node *top_node;};Error_code Stack::push(const Stack_entry &item)/*Post: Stack_entry item is added to the top of      the Stack; returns success or returns a code      of overflow if dynamic memory is exhausted.*/{   Node *new_top = new Node(item, top_node);   if (new_top == NULL) return overflow;   top_node = new_top;   return success;}Error_code Stack::pop()/*Post: The top of the Stack is removed.  If the Stack      is empty the method returns underflow; otherwise it returns success.*/{   Node *old_top = top_node;   if (top_node == NULL) return underflow;   top_node = old_top->next;   delete old_top;   return success;}Error_code Stack::push(Stack_entry item){   Node new_top(item, top_node);   top_node = new_top;   return success;}// Section 4.3:for (int i=0; i < 1000000; i++) {   Stack small;   small.push(some_data);}Stack::~Stack() //  Destructor/*Post: The Stack is cleared.*/{   while (!empty())      pop();}Stack outer_stack;for (int i=0; i < 1000000; i++) {   Stack inner_stack;   inner_stack.push(some_data);   inner_stack = outer_stack;}void Stack::operator = (const Stack &original) //  Overload assignment/*Post: The Stack is reset as a copy of Stack original.*/{   Node *new_top, *new_copy, *original_node = original.top_node;   if (original_node == NULL) new_top = NULL;   else {                         //  Duplicate the linked nodes      new_copy = new_top = new Node(original_node->entry);      while (original_node->next != NULL) {         original_node = original_node->next;         new_copy->next = new Node(original_node->entry);         new_copy = new_copy->next;      }   }   while (!empty())               //  Clean out old Stack entries      pop();   top_node = new_top;            //  and replace them with new entries.}void destroy_the_stack (Stack copy){}int main(){   Stack vital_data;   destroy_the_stack(vital_data);}Stack::Stack(const Stack &original) //  copy constructor/*Post: The Stack is initialized as a copy of Stack original.*/{   Node *new_copy, *original_node = original.top_node;   if (original_node == NULL) top_node = NULL;   else {                         //  Duplicate the linked nodes.      top_node = new_copy = new Node(original_node->entry);      while (original_node->next != NULL) {         original_node = original_node->next;         new_copy->next = new Node(original_node->entry);         new_copy = new_copy->next;      }   }}class Stack {public://  Standard Stack methods   Stack();   bool empty() const;   Error_code push(const Stack_entry &item);   Error_code pop();   Error_code top(Stack_entry &item) const;//  Safety features for linked structures   ~Stack();   Stack(const Stack &original);   void operator =(const Stack &original);protected:   Node *top_node;};void Stack::operator = (const Stack &original){   Stack new_copy(original);   top_node = new_copy.top_node;}// Section 4.4:class Queue {public://  standard Queue methods   Queue();   bool empty() const;   Error_code append(const Queue_entry &item);   Error_code serve();   Error_code retrieve(Queue_entry &item) const;//  safety features for linked structures   ~Queue();   Queue(const Queue &original);   void operator =(const Queue &original);protected:   Node *front, *rear;};Queue::Queue()/*Post: The Queue is initialized to be empty.*/{   front = rear = NULL;}Error_code Queue::append(const Queue_entry &item)/*Post: Add item to the rear of the Queue and return a code of success      or return a code of overflow if dynamic memory is exhausted.*/{   Node *new_rear = new Node(item);   if (new_rear == NULL) return overflow;   if (rear == NULL) front = rear = new_rear;   else {      rear->next = new_rear;      rear = new_rear;   }   return success;}Error_code Queue::serve()/*Post: The front of the Queue is removed.  If the Queue      is empty, return an Error_code of underflow.*/{   if (front == NULL) return underflow;   Node *old_front = front;   front = old_front->next;   if (front == NULL) rear = NULL;   delete old_front;   return success;}class Extended_queue: public Queue {public:   bool full() const;   int size() const;   void clear();   Error_code serve_and_retrieve(Queue_entry &item);};int Extended_queue::size() const/*Post: Return the number of entries in the Extended_queue.*/{   Node *window = front;   int count = 0;   while (window != NULL) {      window = window->next;      count++;   }   return count;}// Section 4.5:int main()/*Post: The program has executed simple polynomial arithmetic      commands entered by the user.Uses: The classes Stack and Polynomial and the functions      introduction, instructions, do_command, and get_command.*/{   Stack stored_polynomials;   introduction();   instructions();   while (do_command(get_command(), stored_polynomials));}bool do_command(char command, Stack &stored_polynomials)/*Pre:  The first parameter specifies a valid calculator command.Post: The command specified by the first parameter      has been applied to the Stack of Polynomial      objects given by the second parameter.      A result of true is returned unless command == 'q'.Uses: The classes Stack and Polynomial.*/{   Polynomial p, q, r;   switch (command) {   case '?':      p.read();      if (stored_polynomials.push(p) == overflow)         cout << "Warning: Stack full, lost polynomial" << endl;      break;   case '=':      if (stored_polynomials.empty())         cout << "Stack empty" << endl;      else {         stored_polynomials.top(p);         p.print();      }      break;   case '+':      if (stored_polynomials.empty())         cout << "Stack empty" << endl;      else {         stored_polynomials.top(p);         stored_polynomials.pop();         if (stored_polynomials.empty()) {            cout << "Stack has just one polynomial" << endl;            stored_polynomials.push(p);         }         else {            stored_polynomials.top(q);            stored_polynomials.pop();            r.equals_sum(q, p);            if (stored_polynomials.push(r) == overflow)               cout << "Warning: Stack full, lost polynomial" << endl;         }      }      break;   //   Add options for further user commands.    case 'q':      cout << "Calculation finished." << endl;      return false;   }   return true;}class Polynomial {public:   void read();   void print();   void equals_sum(Polynomial p, Polynomial q);   void equals_difference(Polynomial p, Polynomial q);   void equals_product(Polynomial p, Polynomial q);   Error_code equals_quotient(Polynomial p, Polynomial q);private:   double value;};void Polynomial::equals_sum(Polynomial p, Polynomial q){   value = p.value + q.value;}struct Term {   int degree;   double coefficient;   Term (int exponent = 0, double scalar = 0);};Term::Term(int exponent, double scalar)/*Post: The Term is initialized with the given coefficient and exponent,      or with default parameter values of 0.*/{   degree = exponent;   coefficient = scalar;}class Polynomial: private Extended_queue {  //  Use private inheritance.public:   void read();   void print() const;   void equals_sum(Polynomial p, Polynomial q);   void equals_difference(Polynomial p, Polynomial q);   void equals_product(Polynomial p, Polynomial q);   Error_code equals_quotient(Polynomial p, Polynomial q);   int degree() const;private:   void mult_term(Polynomial p, Term t);};void Polynomial::print() const/*Post: The Polynomial is printed to cout.*/{   Node *print_node = front;   bool first_term = true;   while (print_node != NULL) {      Term &print_term = print_node->entry;      if (first_term) {  //  In this case, suppress printing an initial '+'.         first_term = false;         if (print_term.coefficient < 0) cout << "- ";      }      else if (print_term.coefficient < 0) cout << " - ";      else cout << " + ";      double r = (print_term.coefficient >= 0)                 ? print_term.coefficient : -(print_term.coefficient);      if (r != 1) cout << r;      if (print_term.degree > 1) cout << " X^" << print_term.degree;      if (print_term.degree == 1) cout << " X";      if (r == 1 && print_term.degree == 0) cout << " 1";      print_node = print_node->next;   }   if (first_term)      cout << "0";  //  Print 0 for an empty Polynomial.   cout << endl;}void Polynomial::read()/*Post: The Polynomial is read from cin.*/{   clear();   double coefficient;   int last_exponent, exponent;   bool first_term = true;   cout << "Enter the coefficients and exponents for the polynomial, "        << "one pair per line.  Exponents must be in descending order." << endl        << "Enter a coefficient of 0 or an exponent of 0 to terminate." << endl;   do {      cout << "coefficient? " << flush;      cin  >> coefficient;      if (coefficient != 0.0) {         cout << "exponent? " << flush;         cin  >> exponent;         if ((!first_term && exponent >= last_exponent) || exponent < 0) {            exponent = 0;            cout << "Bad exponent: Polynomial terminates without its last term."                 << endl;         }         else {            Term new_term(exponent, coefficient);            append(new_term);            first_term = false;         }         last_exponent = exponent;      }   } while (coefficient != 0.0 && exponent != 0);}void Polynomial::equals_sum(Polynomial p, Polynomial q)/*Post: The Polynomial object is reset as the sum of the two parameters.*/{   clear();   while (!p.empty() || !q.empty()) {      Term p_term, q_term;      if (p.degree() > q.degree()) {         p.serve_and_retrieve(p_term);         append(p_term);      }      else if (q.degree() > p.degree()) {         q.serve_and_retrieve(q_term);         append(q_term);      }      else {         p.serve_and_retrieve(p_term);         q.serve_and_retrieve(q_term);         if (p_term.coefficient + q_term.coefficient != 0) {            Term answer_term(p_term.degree,                             p_term.coefficient + q_term.coefficient);            append(answer_term);         }      }   }}int Polynomial::degree() const/*Post: If the Polynomial is identically 0, a result of -1 is returned.      Otherwise the degree of the Polynomial is returned.*/{   if (empty()) return -1;   Term lead;   retrieve(lead);   return lead.degree;}/*************************************************************************/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产精品亚洲精品| 777久久久精品| 在线观看成人小视频| 欧美一区二区视频网站| 国产精品短视频| 另类的小说在线视频另类成人小视频在线| 成人性生交大片免费看中文 | 日韩你懂的在线播放| 中文字幕视频一区| 韩国精品免费视频| 欧美一区二区三区免费在线看| 国产精品天天摸av网| 国产麻豆视频一区| 日韩女优毛片在线| 亚洲第一狼人社区| 色婷婷亚洲精品| 亚洲国产成人私人影院tom| 久久精品国产网站| 欧美一区中文字幕| 午夜一区二区三区视频| 91久久一区二区| 亚洲另类色综合网站| 不卡高清视频专区| 国产三级一区二区| 国产黑丝在线一区二区三区| 精品成人私密视频| 日韩高清不卡一区| 在线电影一区二区三区| 亚洲国产日产av| 在线一区二区三区四区| 亚洲人成网站色在线观看| 不卡影院免费观看| 国产精品国产馆在线真实露脸| 成人午夜在线播放| 日韩一区欧美小说| 99精品视频一区二区| 国产精品久久久久久久久免费桃花| 国产成a人无v码亚洲福利| 久久久青草青青国产亚洲免观| 国产精品综合视频| 中文字幕不卡在线| 91色视频在线| 亚洲综合色在线| 9191国产精品| 奇米影视一区二区三区小说| 日韩欧美一区二区免费| 国产永久精品大片wwwapp| 国产欧美一区二区精品性色| 高清不卡一区二区| 亚洲欧洲美洲综合色网| 色偷偷久久一区二区三区| 亚洲午夜日本在线观看| 欧美一区二区精品久久911| 久久超级碰视频| 国产欧美久久久精品影院| 一本色道久久综合亚洲91| 亚洲中国最大av网站| 日韩一卡二卡三卡| 国产精品456| 亚洲精品国产精华液| 欧美精品少妇一区二区三区 | 亚洲自拍欧美精品| 日韩免费视频一区| 粉嫩aⅴ一区二区三区四区| 日韩毛片在线免费观看| 欧美精品一卡两卡| 国产精品一区二区91| 一区二区三区美女| 精品久久一区二区| 91网址在线看| 裸体在线国模精品偷拍| 中文字幕在线不卡视频| 在线不卡中文字幕播放| 懂色av中文一区二区三区| 亚洲一区在线观看免费 | 久久爱另类一区二区小说| 最新久久zyz资源站| 欧美一级专区免费大片| 99精品视频在线观看| 美女任你摸久久| 亚洲三级久久久| 26uuu久久天堂性欧美| 日本道色综合久久| 国产精品18久久久久久久网站| 亚洲最大的成人av| 国产亚洲欧美日韩俺去了| 欧美日韩在线播放三区四区| 成人午夜在线视频| 久久国产成人午夜av影院| 一区二区三区影院| 久久先锋影音av| 69堂精品视频| 一本久久a久久精品亚洲| 国产高清亚洲一区| 久久aⅴ国产欧美74aaa| 亚洲一区二区美女| 亚洲精品日产精品乱码不卡| 国产欧美日本一区二区三区| 日韩精品一区二区三区视频播放| 欧美综合亚洲图片综合区| 菠萝蜜视频在线观看一区| 精品系列免费在线观看| 天堂资源在线中文精品| 亚洲免费成人av| 国产精品卡一卡二卡三| 国产区在线观看成人精品| 精品国产成人在线影院 | 久久国产剧场电影| 麻豆精品一区二区av白丝在线| 一区二区三区.www| 亚洲欧美经典视频| 亚洲欧美日韩一区二区| 中文字幕亚洲不卡| 亚洲欧美一区二区三区极速播放 | 成人开心网精品视频| 国产精品18久久久久久久久久久久 | 欧美午夜精品免费| 色婷婷激情一区二区三区| 色哟哟国产精品| 色94色欧美sute亚洲线路二 | 亚洲专区一二三| 亚洲一二三区不卡| 亚洲高清免费一级二级三级| 亚洲第一会所有码转帖| 五月天久久比比资源色| 五月天亚洲精品| 免费在线视频一区| 国内精品久久久久影院薰衣草 | 日本91福利区| 久久99精品国产| 国产成人免费高清| 99re这里只有精品6| 色呦呦网站一区| 这里只有精品电影| 国产午夜精品一区二区三区视频 | 99精品欧美一区二区三区综合在线| 9人人澡人人爽人人精品| 91丨porny丨户外露出| 91黄色免费网站| 欧美一区二区三区四区高清| 精品对白一区国产伦| 欧美国产禁国产网站cc| ㊣最新国产の精品bt伙计久久| 亚洲一二三四区不卡| 久久电影国产免费久久电影| 成人免费黄色在线| 欧洲亚洲国产日韩| 欧美xingq一区二区| 亚洲天堂成人在线观看| 日韩成人精品在线观看| 国产成人精品一区二区三区四区 | 日韩女优电影在线观看| 国产精品高潮呻吟| 视频在线在亚洲| 国产成人精品亚洲午夜麻豆| 精品视频一区三区九区| 2023国产精华国产精品| 亚洲综合色区另类av| 国产成人精品一区二| 欧美日韩在线不卡| 精品国产91亚洲一区二区三区婷婷| 久久久久9999亚洲精品| 欧美在线短视频| 91精品国产综合久久精品图片| 精品电影一区二区三区| 亚洲欧洲在线观看av| 极品美女销魂一区二区三区免费| www.欧美.com| 欧美精品一区二区三区蜜桃视频| 一区二区三区四区精品在线视频 | 亚洲激情自拍偷拍| 国产精品一区二区三区四区| 在线观看免费亚洲| 国产精品视频一区二区三区不卡| 免费人成在线不卡| 欧美伊人久久久久久午夜久久久久| 久久精品免费在线观看| 婷婷中文字幕一区三区| 91亚洲精品久久久蜜桃网站| 久久婷婷国产综合国色天香 | 91精品国产欧美一区二区成人| 国产精品成人一区二区艾草 | 久久午夜电影网| 蜜臂av日日欢夜夜爽一区| 欧美视频在线一区| 亚洲美女视频在线观看| 成人美女视频在线看| 国产三级精品视频| 国内不卡的二区三区中文字幕| 91精品国产综合久久精品性色| 有坂深雪av一区二区精品| av一二三不卡影片| 欧美极品美女视频| 国产一区二区福利| 日韩免费高清av| 麻豆久久久久久久| 日韩视频一区二区| 蜜桃视频第一区免费观看| 日韩色在线观看| 久久99精品久久久久久动态图|