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

📄 单链表.cpp

📁 包含几十个有关数据结构算法的源代码 包括栈 队列 树图等 是初学者的最佳选择
💻 CPP
字号:
#include <iostream.h>
class Time{
public:
    Time()
    { h = m = 0;
    }
    Time(int hr, int min)
    { if (hr>=0 && hr<24) h = hr; else h = 0;
          if (min>=0 && min<60) m = min; else m = 0;
		  cout<<h<<"\n"<<m<<endl;
          }
  private:
    int h, m;
};
///
// 单链表:
struct QueueNode{
    Time val;
    QueueNode *next;
};
//////////////
class Queue{
private:
    struct QueueNode *f,*b;
public:
        Queue(){
            f=b=new QueueNode;
            b->next=NULL;

        }
        Queue(Time val){

                      f=b=new QueueNode;
                      b->val=val;
                    b->next=NULL;
                    }
                  add(Time i){
QueueNode *newcell = new QueueNode;
newcell->val=i;
newcell->next=NULL;
b->next=newcell;
b=newcell;
}
}
//////////////
  main(){
  Time t(12,12);
  Time t2(3,3);
  Queue q;
  q.add(t);
}  

⌨️ 快捷键说明

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