Em viết để in ra danh sách bằng stack nhưng lỗi chỗ pRun , em không hiểu tại sao bị lỗi chỗ đó , anh chị nào giúp em , em cảm ơn !
#include<iostream>
using namespace std;
struct Node {
int data;
Node *next;
};
struct Stack {
Node *top;
int count;
};
bool isEmptyStack(Stack *s)
{
if (!s)
return true;
if (s->top == NULL || s->count == 0)
return true;
else
return false;
}
Node *Push(Stack *s, int data) // them Node vao dau danh sach
{
if (!s)
return NULL;
Node *nNode = new Node;
nNode->data = data;
nNode->next = NULL;
if (isEmptyStack(s)) {
s->top = nNode;
s->count++;
} else {
nNode->next = s->top;
s->top = nNode;
}
s->count++;
return s->top;
}
void Print(Stack *s)
{
Node *pRun = NULL;
if (!s)
return;
else{
Node *pRun = s->top;
while (pRun != NULL) {
cout << pRun->data;
pRun = pRun->next;
}
cout << endl;
}
}
int main()
{
Stack *s = new Stack;
Node *top = NULL;
int count = 0;
Push(s, 3);
Push(s, 4);
Print(s);
system("pause");
return 0;
}

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?