-1
我有这个c代码,关于多个if语句.. 所有语句都很好地工作,除了最后一个.. 它被其他if语句激活并因此破坏结果.. 任何建议?其他多个if语句
for (i=0; i<(total); i++)
{
for (n=0; n<((total)/4); n++)
{
if (i==(0+(n*4)) && i<(total-5)&&(array[i]==0))
{
array[i]=1;
i=n=500;
break;
}
else if ((i==(3+(n*4)))&&i<(total-5)&&(array[i]==0))
{
array[i]=1;
i=n=500;
break;
}
else if (i==(total)&&(array[i]==0))
{
array[i]=1;
i=n=500;
break;
}
else if (i==(total-1)&&(array[i]==0))
{
array[i]=1;
i=n=500;
break;
}
else
printf("**Something**");
}
}
}
存在C.没有特殊的'别人if'它只是一个组合。 –
只是将你最后的'else'语句替换为'else if',你应该没问题。 **'c' **没有像其他语言那样隐含'else if'语句**(例如:Python:'elif')**。 –