用C语言(tc)编写程序:在屏幕上动态显示入栈,出栈操作

来源:百度知道 编辑:UC知道 时间:2024/05/05 10:28:54
rt,利用TC图形处理功能,在屏幕上动态显示入栈,出栈操作.
一楼的,我要的不是入栈和出栈,是在tc中画出入栈和出栈的过程

#include <stdio.h>
#define MAX 100
int stack[MAX];
int top;
int bottom;
void push(){
int a;
if(top==MAX){
fprintf(stderr,"Error:the stack is full\n");
return;
}
scanf("%d",&a);
stack[top]=a;
top++;
}
int pop(){
if(top==bottom){
fprintf(stderr,"Error:the stack is empty\n");
return;
}
top--;
return stack[top+1];
}