/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param value int整型
* @return 无
*/
typedef struct StackNode //栈的数据域
{
int data;
struct StackNode *next;
}StackNode;
typedef struct pStack //栈的指针域
{
StackNode *top;
StackNode *tail;
}pStack;
pStack pstack={NULL, NULL}; //指向栈的指针
void push(int value ) {
// write code here
StackNode *D = NULL;
D = (StackNode*)calloc(1, sizeof(StackNode));
D->data = value;
D->next = pstack.top;
pstack.top = D;
if (pstack.tail == NULL)
{
pstack.tail = pstack.top;
}
}
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param 无
* @return 无
*/
void pop() {
// write code here
StackNode *P = NULL;
P = pstack.top->next;
free (pstack.top);
pstack.top = P;
}
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param 无
* @return int整型
*/
int top() {
// write code here
return pstack.top->data;
}
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param 无
* @return int整型
*/
int min() {
// write code here
int i = pstack.top->data;
StackNode *p = pstack.top->next;
while (p)
{
if (i > p->data)
{
i = p->data;
}
p = p->next;
}
return i;
}