資源簡介
簡單隊列操作,vc++實現。隊列類實現,小弟新手,大神莫黑
代碼片段和文件信息
#include?
using?namespace?std?;
struct?Node{???
?int?data?;????
?Node?*?next?;????
?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)
return?false;????????
Node*?p?=?head?;????????
if(head->next?==?NULL)
tail?=?NULL?;????????
head?=?head->next?;????????
int?data?=?p->data?;????????
delete?p?;????????
return?data?;????
}????
voi
- 上一篇:Vc++/MFC下 Json解析
- 下一篇:C++蟻群算法的機器人路徑規劃
評論
共有 條評論