void minStackPop(MinStack *stack) { int top = minStackTop(stack); if(top <= minStackGetMin(stack)) stack->top_min--; stack->top_data--; }
int main() { MinStack* stack = (MinStack*)malloc(sizeof(MinStack)); minStackCreate(stack, 5); minStackPush(stack, 2); minStackPush(stack, 0); minStackPush(stack, 3); minStackPush(stack, 0); printf_s("%d ", minStackGetMin(stack)); minStackPop(stack); printf_s("%d ", minStackGetMin(stack)); minStackPop(stack); printf_s("%d ", minStackGetMin(stack)); minStackPop(stack); printf_s("%d ", minStackGetMin(stack)); printf_s("\n"); return 0; }
int main(void){ MinStack *stack=NULL; minStackPush(stack,-3); int res=minStackGetMin(stack); printf(" %d",res); }