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

 时间:2024-10-15 05:01:11

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 Nod髫潋啜缅e{ 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:输出语句和简单的运算符
  • 热门搜索
    汉字真有趣手抄报 三国演义手抄报 手抄报图片大全 关于感恩的手抄报 汤姆索亚历险记手抄报 爱眼护眼手抄报内容 关于节约用水的手抄报 端午节的手抄报 孝亲敬老手抄报 重阳节手抄报