Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 我的循环没有运行_Loops_Nested Loops - Fatal编程技术网

Loops 我的循环没有运行

Loops 我的循环没有运行,loops,nested-loops,Loops,Nested Loops,当我为一个项目Euler问题(39)运行这段代码时,它不会运行最后一个循环,只是跳过了它。我之前对嵌套循环也有类似的问题,但我设法解决了这些问题……不知怎么的。我想简化我的代码,但我需要它首先工作 我试过,如果(真的){},出于某种原因,这可能会有所帮助。我没有删除它,因为我想让它尽可能接近我运行的内容 谢谢。我有一个坏习惯,先用==代替: int[] right = new int[1010](); // The brackets here will

当我为一个项目Euler问题(39)运行这段代码时,它不会运行最后一个循环,只是跳过了它。我之前对嵌套循环也有类似的问题,但我设法解决了这些问题……不知怎么的。我想简化我的代码,但我需要它首先工作

我试过,如果(真的){},出于某种原因,这可能会有所帮助。我没有删除它,因为我想让它尽可能接近我运行的内容

谢谢。我有一个坏习惯,先用==代替:

int[] right = new int[1010](); // The brackets here will 
                               //initialize the memory to 0
第二::

// No need for this, as the memory is already initialized to 0
// Changed i == 1009 to i <= 1009
for(i = 0; i <= 1009; i++ )
{
 right[i] = 0;
}
//不需要这样做,因为内存已初始化为0

//将i==1009更改为i,其中最后一个循环中的
int s=0
“s==999”???那应该是“s”
// No need for this, as the memory is already initialized to 0
// Changed i == 1009 to i <= 1009
for(i = 0; i <= 1009; i++ )
{
 right[i] = 0;
}
// Changed s == 999 to s <= 999
for(; s <= 999; s++ )
{
}