我认为我的逻辑是正确的,但是 while 无限循环,输出为零。这是我的代码:
int currentMSD, currentNum = num;
if (currentNum >= 0 && currentNum < 100) {
currentMSD = 10;
} else if (currentNum >= 100 && currentNum < 1000) {
b1 = b * msd;
b2 = num3 - b1;
num3 = b2;
switch(b) {
case 1:
cout << "one ";
break;
case 2:
cout << "two ";
cout << "five ";
break;
case 6:
cout << "six ";
break;
case 9:
cout << "nine ";
break;
case 0:
cout << "zero ";
break;
}
}
cout << '\n';
}