C++链表实现堆栈:LinkList:Build a linklist using C++ class Stack
2009-12-09 16:07
501 查看
// Stack.cpp : Defines the entry point for the console application.
#include
"stdafx.h"
#include
"iostream"
using
namespace std;
typedef
struct
_node
int
data;
struct
_node *next;
class
MyStack
private
:
public
:
while
(head)
delete
p;
void
Initialize(Node *h)
if
(head==NULL)
bool
Empty()
if
(head==NULL)
return true
;
else
return false
;
void
pushh(Node* h)
if
(head==NULL)
else
{
h->next=head;
head=h;
}
}
int
pop()
if
(head==NULL)
return
-1;
else
{
int
val=head->data;
return
val;
return
head;
void
_tmain(int
argc, _TCHAR* argv[])
sizeof
(Node));
sizeof
(Node));
if
(s.Empty())
"the stack is empty"
<<endl;
else
cout<<s.top()->data;
cin.get();
}
cout<<
ph->data=2;
s.pushh(ph);
s.pop();
p->data=1;
p->next=NULL;
s.Initialize(p);
Node* ph=(Node*)malloc(
{
MyStack s;
Node* p=(Node*)malloc(
}
};
}
}
Node* top()
{
head=head->next;
{
head=h;
{
}
{
head=h;
}
{
}
}
{
Node *p=head;
head=head->next;
MyStack()
{
head=NULL;
}
~MyStack()
{
Node* head;
{
}Node;
{
//
#include
"stdafx.h"
#include
"iostream"
using
namespace std;
typedef
struct
_node
int
data;
struct
_node *next;
class
MyStack
private
:
public
:
while
(head)
delete
p;
void
Initialize(Node *h)
if
(head==NULL)
bool
Empty()
if
(head==NULL)
return true
;
else
return false
;
void
pushh(Node* h)
if
(head==NULL)
else
{
h->next=head;
head=h;
}
}
int
pop()
if
(head==NULL)
return
-1;
else
{
int
val=head->data;
return
val;
return
head;
void
_tmain(int
argc, _TCHAR* argv[])
sizeof
(Node));
sizeof
(Node));
if
(s.Empty())
"the stack is empty"
<<endl;
else
cout<<s.top()->data;
cin.get();
}
cout<<
ph->data=2;
s.pushh(ph);
s.pop();
p->data=1;
p->next=NULL;
s.Initialize(p);
Node* ph=(Node*)malloc(
{
MyStack s;
Node* p=(Node*)malloc(
}
};
}
}
Node* top()
{
head=head->next;
{
head=h;
{
}
{
head=h;
}
{
}
}
{
Node *p=head;
head=head->next;
MyStack()
{
head=NULL;
}
~MyStack()
{
Node* head;
{
}Node;
{
//
相关文章推荐
- 栈 (Stack) 的C++实现(链表方法)
- C++用数组和链表分别实现Stack
- C++ 队列(queue)堆栈(stack)实现基础
- linkList C++简单链式链表的实现
- 递归,迭代,堆栈三种方式实现单链表反转(C++)
- C++实现的链表,LinkList
- C++ 使用单向链表实现Stack
- C++学习笔记(四)指针实现的链表、堆栈、队列、二叉查找树
- LeetCode学习之-225. 利用队列实现堆栈(Implement Stack using Queues)
- C++用数组和链表分别实现Stack
- C++实现双向链表
- C++链表类的三种使用方法(学生信息管理系统的实现)
- C++实现顺序表和单链表
- C++实现链表的进本操作及测试用例
- [C++]实现异质链表
- 双向循环链表删除算法的C++程序实现
- 堆栈的简单C++实现
- 【C++】实现双向链表的所有操作,包括逆置双链表(三种方法)
- (C++版)链表(二)——实现单项循环链表创建、插入、删除等操作
- 学生管理系统c++链表实现