比如說:
①除以零②數組越界:int a[3]; a[10000000]=10;③指針越界:int * p; p=(int *)malloc(5 * sizeof(int)); *(p+1000000)=10;④使用已經釋放的空間:int * p; p=(int *)malloc(5 * sizeof(int));free(p); *p=10;⑤數組開得太大,超出了棧的范圍,造成棧溢出:int a[100000000];一般來說,在oj上做題都把數組設成全局變量,減少5出現的可能。
有的時候再出現這樣的錯誤還會給提示Runtime Error(ARRAY_BOUNDS_EXCEEDED) // array bounds exceed 數組越界Runtime Error(DIVIDE_BY_ZERO) //divisor is nil 除零Runtime Error(access_VIOLATION) //illegal memory access 非法內存讀取Runtime Error(STACK_OVERFLOW) //stack overflow 系統棧過載這樣可以照著上面查找錯誤。
新聞熱點
疑難解答