// http://p.ip.fi/q2hA -this is link to the code written below, where it is expressed in an understandable format.
Blockquote
#include <stdio.h>
#include<stdlib.h>
struct stack
{
int top;
int array;
};
struct stack create(int n)
{
struct stack s = (struct stack)malloc(nsizeof(struct stack));
s->top = -1;
s->array = (int)malloc(nsizeof(int));
return s;
}
struct stack push(struct stack* s, int x)
{
s->array[++s->top] = x;
return s;
}
struct stack* pop(struct stack* s)
{
if(s->top == -1)
{
printf("EMPTY\n");
return s;
}
s->top--;
return s;// s->array[s->top--];
}
void min(struct stack* s)
{
if(s->top == -1)
{
printf(“EMPTY\n”);
return ;
}
int min = s->array[0];
for (int i = 1; i <= s->top; ++i)
{
//printf("%d %d “,min,s->array[i]);
if(s->array[i]<min)
{
min = s->array[i];
}
}
printf(”%d\n",min);
}
int main()
{
int n;
scanf("%d",&n);
struct stack *s = NULL;s = create(n);
for (int i = 0; i < n; ++i)
{
char st[7];
scanf("%s",&st);
if(st[1] == ‘U’)
{
int x;
scanf("%d",&x);
s = push(s,x);
}
else if(st[1] == ‘O’)
{
s = pop(s);
}
else
{
min(s);
}
}
}
Blockquote