www.pudn.com > zb.rar > 003.c
#include#define MAX 100 int S[MAX]; int top1=-1; int top2=MAX; push() /*压入堆栈*/ { int x,i,num; if(top1==top2) printf("Overflow.\n"); else {printf("please input the data you want to push.\nthe data is:"); scanf("%d",&x); printf("please input the stack you want to operate.\n\t*1 stack1.\n\t*2 stack2.\nthe choice is:"); scanf("%d",&num); if(num==1) {top1++; S[top1]=x; printf("Successfully.\n"); } else if(num==2) {top2--; S[top2]=x; printf("Successfully.\n"); } else printf("ERROR!\n"); } for(i=0;i 3)) printf("ERROR!please input again.\n"); }while((choice<1)||(choice>3)); return(choice); } stack() { int choice; do {choice=show3(); switch(choice) {case 1:{push(); break; } case 2:{pop(); break; } case 3:break; } }while(choice!=3); }