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