#1901: 發生了RE


abalone (偷偷來)


執行時發生錯誤 (SIGSEGV)(11)!!
Segmentation fault, an address reference boundary error.(記憶體區段錯誤)
可能原因為:
* 通常為使用超過陣列範圍
* 指標指向不正確位址!
* 陣列初始化不正確!
* 嘗試在執行時期定義陣列長度!
sh: line 1: 24700 程式記憶體區段錯誤

我不知道哪裡發生了問題,原程式在Dev下是可編譯且執行的,請大家幫我看一下,謝謝

 程式碼如下

 #include<stdio.h>
#include<stdlib.h>

int main()
{
   char i,j,a;
   unsigned char tab[23][23]={0};
   tab[0][0]=1;
     tab[1][0]=1;
     for(i=2;i<23;i++)
        for(j=0;j<23;j++)
        {
           tab[i][j]+=tab[i-1][j]*i;
           if (tab[i][j]>=10)
           {
              tab[i][j+1]+=tab[i][j]/10;
              tab[i][j]%=10;
           }
        }
   while(scanf("%d",&a)!=EOF)
   {
     for(j=22;j>=0;j--)
        if(tab[a][j]!=0)
           break;
     for(;j>=0;j--)
        printf("%d",tab[a][j]);
     printf("\n");
   }
   return 0;
}