好吧,我有一个很好的方式完成的代码,并使用增量++和减量 - 运算符。如何避免使用++和 - 运营商
unsigned int atob(const char* input)
{
int i = 0;
while (input[i] == '0' || input[i] == '1') i++;
unsigned result = 0;
unsigned currentBit = --i;
while ((*input == '0') || (*input == '1')) {
char isCurrentBitSet = *input == '1';
unsigned setValue = (isCurrentBitSet << currentBit--);
result |= setValue;
input++;
}
return result;
}
现在,我需要摆脱所有的DEC( - )/ INC(++),除了输入++在while语句的底部。我对如何执行这个实现感到困惑。
你需要摆脱增量和减量的原因是什么? – EvilTeach
@EvilTeach:我只是在猜测,但我会说这是他的老师(教授,无论如何)间接试图推动他考虑不同的解决方案。 –
有点接近。我只是为了学习而努力! – Jordan