VC++6.0程序设计系列-队列的实现

 时间:2026-02-12 12:54:45

1、新建工程01

VC++6.0程序设计系列-队列的实现

2、新建工程02

VC++6.0程序设计系列-队列的实现

3、新建工程03

VC++6.0程序设计系列-队列的实现

4、新建工程04

VC++6.0程序设计系列-队列的实现

5、新建工程05

VC++6.0程序设计系列-队列的实现

6、新建工程06

VC++6.0程序设计系列-队列的实现

7、新建工程07

VC++6.0程序设计系列-队列的实现

8、添加代码

#include <iostream>using namespace std ;struct Node{    int data ;    Node * next ;    Node():data(0),next(NULL){}    Node(int d):next(NULL){data=d ;}};class Queue{private :    Node *head ;    Node *tail ;public :    Queue(){        head = NULL ;        tail = head ;    }        int Pop() {        if(head == NULL) throw "error" ;        Node* p = head ;        if(head->next == NULL)tail = NULL ;        head = head->next ;        int res = p->data ;        delete p ;        return res ;    }    void Push(int d) {        Node * p = new Node(d) ;        if(head == NULL) {            head = p ;            tail = p ;        }        else {            tail->next = p ;            tail = p ;        }    }    bool Empty(){        return head == NULL ;    }};int main(){    int i = 0 ;    int ds [] = {1,2,3,4,5,6} ;    Queue q ;    int n = sizeof(ds)/sizeof(int) ;    for(i = 0 ; i < n ;i++)    {        q.Push(ds[i]) ;    }    for(i = 0 ; i < n ;i++){        cout<<q.Pop()<<" ";    }    cout<<endl;    return  0 ;}

VC++6.0程序设计系列-队列的实现

9、调试运行

VC++6.0程序设计系列-队列的实现

  • VSCode 设置中文
  • c# 设置单元格数值格式
  • 使用CXF发布WebService服务端
  • PyCharm如何新建空项目
  • 使用VS开发Python:输出语句和简单的运算符
  • 热门搜索
    新鲜竹笋的做法 兔子肉的做法 豆沙馅的做法 对讲机怎么用 火锅的做法 京酱肉丝家常做法 三杯鸡的做法 豆腐汤的做法 炸酱面做法 扁豆角的做法