原程序如下,我想用栈来做,我现在想让方格的序号依次入栈,用printf()函数将它们显示出来,可能是递归回搠时出了问题。谢谢帮我一下。#include "stdio.h"
#define STACK_INIT_SIZE 400;
struct SqStack{
    int *base;
    int *top;
    int stacksize;
};
int HTry1[8]={-2,-1,1,2,2,1,-1,-2};
int HTry2[8]={1,2,2,1,-1,-2,-2,-1};
int ch[64]={0,0,0};          /*用来标识对应方格是否走过*/
int arr[8][8];               /*记录走到当前方格的k值*/
int i,j,k;
int l=0;
int n=0;                     /*用来表示走过的方格数*/
forward(struct SqStack *S);
void back(struct SqStack *S);InitStack(struct SqStack *S){                 /*构造一个空栈*/
    S->base=malloc(400);
    S->top=S->base;
    S->stacksize=STACK_INIT_SIZE;
}void Push(struct SqStack *S,int e){
    *S->top=e;
    S->top++;
    n++;
}void Pop(struct SqStack *S,int *a){
    S->top--;
    *a=*(S->top);
    n--;
}void print(struct SqStack *S){
    int e;
    while (!(S->top==S->base)){
        Pop(S,&e);
        printf("%d\t",e);
    }
    }void back(struct SqStack *S){
    if(n<64){
    int e;
    Pop(S,&e);
    ch[e]=0;
    l=arr[i-1][j-1];
    i=i-HTry1[l];
    j=j-HTry2[l];
    if(l==7) back(S);/*此回搠点也无路可走,继续回搠*/
    if(l<7){
            l++;
            forward(S);
            }
                   }    }
forward(struct SqStack *S){
    int x;
    int y;
    if(n<64){
    for (k=l;k<8;k++){
        x=i+HTry1[k];
        y=j+HTry2[k];            if(x>0&&x<9&&y>0&&y<9&&ch[(x-1)*8+(y-1)]==0){/*向前一个点*/
                i=x;
                j=y;
                Push(S,(x-1)*8+(y-1));
                ch[(x-1)*8+(y-1)]=1;
                arr[i-1][j-1]=k;        /*保留k值,回搠时使用*/
                l=0;
                forward(S);
                }           else if(k==7) back(S);/*无路 返回*/
                        }
           }
       }
main(){
    struct SqStack stack1;
    InitStack(&stack1);
    printf("Please enter the row and column of the starting point.\n");
    scanf("%d,%d",&i,&j);/*输入行数和列数*/
    Push(&stack1,(i-1)*8+(j-1));
    ch[(i-1)*8+(j-1)]=1;
    forward(&stack1);
    print(&stack1);
    getch();
    }