示例#1
0
文件: main.cpp 项目: fr33h8r/LabWorks
void main()
{
	srand(time(0));
	Stack ST;
	char c;
	// пока стек не заполнится
	while(!ST.IsFull()){
        c=rand()%4+2;
		ST.Push(c);
	}
	// пока стек не освободится
	while(c=ST.Pop()){
       		cout<<c<<" ";
	}
	cout<<"\n\n";
}
示例#2
0
文件: main.cpp 项目: CCJY/coliru
Stack operator+(const Stack& s) const
{
// copy the first list
Stack t = *this;
Stack u = *this;
Node *n = s.top;
 
// iterate through the second list and copy each element to the new list
while (n != NULL && !t.IsFull())
{
t.Push(n->data);
n = n->link;
}

n = t.top;
while (n != NULL && !t.IsEmpty())
{
u.Push(n->data);
t.Pop();
n = t.top;
}
 
return u;
}
示例#3
0
TEST(Stack, isnt_full_stack_IsFull_0)
{
	Stack<int> *S = new Stack<int>;
	S->Push(1);
	EXPECT_EQ(0, S->IsFull());
}
示例#4
0
TEST(STACK, can_check_fullness)
{
	Stack<int>* s = new Stack<int>;
	s->Push(5);
	EXPECT_EQ(0, s->IsFull());
}