内存操作错误!
#include "stdio.h"#define ARR_LEN 199
int main(void)
{
int array[ ARR_LEN ];
int count = 0,temp,value;
int i,j;
printf("请输入一个数:");
scanf("%d",&value);
for(i = 0;i< ARR_LEN;i++)
array[i] = -1;
array[i] = 1;
for(j = 2;j <= value;j ++)
{
while(array[i] !=-1 || count != 0)
{
if(array[i] != -1)
{
temp = array[i];
array[i] = (array[i] * j +count) % 10;
count = (temp * j +count) / 10;
i --;
}
else
{
if( count != 0)
{
array[i] = count % 10;
count = count / 10;
i--;
}
}
}
i = ARR_LEN;
count = 0;
}
for(i = 0;i<= ARR_LEN; i ++)
{
if(array[i] != -1)
printf("%d",array[i]);
}
printf("\n");
return 0;
}
一个简单的大数阶乘问题,程序运行结束会出现内存错误,请高手指点~~