⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queue.h

📁 用C++Builder写的数据结构队列问题的程序。希望对大家有用。
💻 H
字号:
#include "iostream.h"
#define null 0

class queue
{
 int length;
 class node
 {
 public:
  char *data;
  node *next,*prev;   
  node()
  {
   data=new char[];
  }
 };
 node *head,*tail;
 
public: 

 queue()
 {
  node *h,*t;
  h=new node;
  t=new node;
  h->next=t;
  h->prev=null;
  t->prev=h; 
  t->next=null;
  head=h;
  tail=t;
 }
 
 bool test_empty()
 {
  if(head->next==tail) return true;
  else return false;   
 }
 
 void join_queue()
 {
  node *q;
  q=new node;
  cout<<"请输入加入的成员:"; 
  cin>>q->data;
  q->next=tail;
  q->prev=tail->prev;
  tail->prev->next=q;
  tail->prev=q;   
 } 
 
 void del_queue()
 {
  if(head->next==tail) cout<<"队为空!无法删除。"<<endl;
  else 
  {
   head->next->next->prev=head;
   head->next=head->next->next;
  }
 }

 void show_queue(bool b)
 {
  node *p;
  p=head->next;
  if(b) cout<<"队为空!"<<endl;
  while(p!=tail)
  {
   cout<<p->data<<"  ";
   p=p->next;
  }
  cout<<"\n";
 }
}; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -