1、新建工程01
2、新建工程02
3、新建工程03
4、新建工程04
5、新建工程05
6、新建工程06
7、新建工程07
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 ;}
9、调试运行