這個代碼運行時只能輸入4個以內的數有輸出4個以上就沒有輸出了求大神看看#include#include#defineStack_Size50typedefstructSeqstack{intelem[Stack_Size];inttop...
這個代碼運行時只能輸入4個以內的數有輸出 4個以上就沒有輸出了 求大神看看 #include #include #define Stack_Size 50 typedef struct Seqstack{ int elem[Stack_Size]; int top; }Seqstack; void Initstack(Seqstack *S);/*初... 這個代碼運行時只能輸入4個以內的數有輸出 4個以上就沒有輸出了 求大神看看 #include #include #define Stack_Size 50 typedef struct Seqstack{ int elem[Stack_Size]; int top; }Seqstack; void Initstack(Seqstack *S);/*初始化*/ int Push(Seqstack *S,int x);/*順序棧進棧*/ int Pop(Seqstack *S,int x);/*出棧*/ int main() { Seqstack *S; int a; Initstack(S); printf("請輸入插入個數:"); scanf("%d",&a); printf("請輸入這些數:"); Push(S,a); printf("出棧順序為:"); Pop(S,a); printf("\n"); return 0; } void Initstack(Seqstack *S) { S->top=-1; } int Push(Seqstack *S,int x) { for(int i=0;itop++; scanf("%d",&S->elem[S->top]); } } int Pop(Seqstack *S,int x) { for(int i=0;ielem[S->top]); S->top--; } } 展開
展開