Untitled

 avatar
unknown
plain_text
2 years ago
877 B
6
Indexable
#include<iostream> // stack bang mang
using namespace std;
int stack [100];
int top =-1;

void push(int x){
	top++;
	stack[top] =x;
}

int pop(){
	int x = stack[top];
	top--;
	return x;
}

bool IsEmpty(){
	return top  == -1;
}

int main(){
	for(int i=0; i< 10; i++){
		push(i);
	}
	cout << pop();
	return 0;
}






//queue bang mang
#include<iostream>
#define max 10000000
using namespace std;
int queuex[100];
int queuey[100];
int front= -1;
int	rear=-1;
int pushq(int x,int y){
	if(rear == max-1) rear =-1;
	rear++;
	queuex[rear]=x;
	queuey[rear]=y;
}

int pop(){
	if(front == max-1) front =-1;
	front++;
	return queue[front];
}
bool IsEmpty(){
	return front == rear;
}	

void BFS(int x, int y){
	visit[];
	push(x,y);
	while(!isEmpty()){
		pop();
		int tempx = queuex[front];
		int tempy = queuey[front];
	}
}
Editor is loading...