Sử dụng mảng cài đặt stack

Mọi người cho mình hỏi code mình sai chỗ nào mà khi chạy nó chỉ hiện như ảnh :frowning:
sửa chỗ nào để chạy được ạ

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std

#define MAX 100

typedef struct stack
{
	int top;
	int nut[MAX];
}stack;

void Stack_Init (stack &s)
{
	s.top=0;
}
int Stack_Empty(stack s)
{
	return(s.top==0);
}

int Stack_full(stack s)
{
	return(s.top==MAX);
}

void Push(stack &s, int x)
{
	if (!Stack_full(s))
	{
		s.nut[s.top]=x;
		s.top++;
	}
	else
	{
		cout<< "stack full";
	}
}
int Pop(stack s)
{
	if (!Stack_Empty(s))
	{
		return s.nut[s.top--];
	}
	else
	{
		cout<<"stack empty";
	}
}
int Top(stack s)
{
	if (!Stack_Empty(s))
	{
		return s.nut[s.top];
	}
	else
	{
		cout<<"stack empty";
	}
}
//nhap
void input (stack &s)
{
    int n;
    int x;
    do
    {
        cout<<"Nhap so phan tu cua Stack ";
        cin>> n;
    } 
	while (n>MAX || n<1);
    for (int i=0; i<n; i++)
    {
        cout<<"Nhap phan tu thu "<<i+1<<" ";
        cin>>x;
        Push(s,x);
    }
}
void output(stack s)
{
	for(int i = s.top-1; i>=0; i--)
	{
		cout<<s.nut[i]<<" ";
	}
}
int main(int argc, char const *argv[])
{	
	stack s;
	Stack_Init(s);
	input(s);
	Push(s, 10);
	output(s);
	cout<<"Top = "<<Top(s);
	cout<<"Pop = "<<Pop(s);
	return 0;
}

đọc xem nó báo bug gì. Thiếu “;” sau namespace std rồi nó có build dc đâu chạy.

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