#include <stdio.h>
int stack[100];
int top = -1;
void push(int x){
stack[++top] = x;
}
int pop(){
return stack[top--];
}
int main(){
int list[] = {1, 2, 3, 4, 0};
for(int i = 0; i < 5; i++){
if(list[i] != 0){
push(list[i]);
} else {
pop();
}
}
if(top >= 0)
printf("%d", stack[top]);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: