为什么在VC++6.0里显示乱码
intmain(void){doubledata[100];doublesum=0.0;doublejie_guo=0.0;for(inti=0,intj=0;i<100...
int main (void)
{
double data [100];
double sum = 0.0;
double jie_guo = 0.0;
for (int i = 0,int j = 0; i < 100; ++i,j += 2)
{
data[i] = 1/(j+2)*(j+3)*(j+4);
sum += data[j]-data[j+1];
}
jie_guo = sum * 4 + 3;
printf ("data[100]的各元素总和乘以4再加3的值是:%lf\n", jie_guo);
return 0;
}
//VC++6.0显示data[100]的各元素总和乘以4再加3的值是:1.#QNAN0 展开
{
double data [100];
double sum = 0.0;
double jie_guo = 0.0;
for (int i = 0,int j = 0; i < 100; ++i,j += 2)
{
data[i] = 1/(j+2)*(j+3)*(j+4);
sum += data[j]-data[j+1];
}
jie_guo = sum * 4 + 3;
printf ("data[100]的各元素总和乘以4再加3的值是:%lf\n", jie_guo);
return 0;
}
//VC++6.0显示data[100]的各元素总和乘以4再加3的值是:1.#QNAN0 展开
2个回答
2015-10-11
展开全部
sum += data[j]-data[j+1]; //你的data[j]在i>49后就会数组越界
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询