Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.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
如何解决这个崩溃的C代码?_C_Arrays_While Loop_Crash - Fatal编程技术网

如何解决这个崩溃的C代码?

如何解决这个崩溃的C代码?,c,arrays,while-loop,crash,C,Arrays,While Loop,Crash,所以我在用C语言编写Euler的φ函数。在我遇到这段代码并崩溃之前,一切似乎都很正常 while(a[i] != 0 || a[i]!= 1) { m=m*((a[i]-1)/a[i]); i++; } 在程序编写此代码之前,用户输入一个值,然后确定基本因子 a[i] != 0 || a[i] != 1 这总是正确的,因为数字不能同时为0和1。当[i]为零时,您可能会遇到零除条件 我猜你是想写信 a[i] !=

所以我在用C语言编写Euler的φ函数。在我遇到这段代码并崩溃之前,一切似乎都很正常

while(a[i] != 0 || a[i]!= 1)
        {
            m=m*((a[i]-1)/a[i]);
            i++;
        } 
在程序编写此代码之前,用户输入一个值,然后确定基本因子

a[i] != 0 || a[i] != 1
这总是正确的,因为数字不能同时为0和1。当[i]为零时,您可能会遇到零除条件

我猜你是想写信

a[i] != 0 && a[i] != 1

但是我不能确定这一点,因为我看不到您的代码的其余部分。但是,此更改将避免零分

你可能想在i大于数组长度之前停止。数组中有什么?数组中是否嵌入了某些终止条件?可能是| |->&&因为a[i]!=0 | a[i]!=1始终正确找到素因子后,我用零填充数组的其余部分。