我使它顯示了股息,以便人們可以破解代碼沒有太多麻煩。它曾經工作過,但之後我不知道我做了什麼來使它停止工作。它適用於正整數。它應該顯示與用戶輸入相關的數字。部門停止工作負數
#include <iostream> // Necessary header
using namespace std;
int main()
{
signed int Input, Divisor, Dividend, MSD;
cout << "Input:";
cin >> Input;
Divisor = 1;
Dividend = Input;
if (Input < 0)
{
Dividend *= -1;
cout << "minus ";
}
cout << Dividend;
while (Dividend > 9)
{
Divisor = Divisor * 10;
Dividend = Dividend/10;
}
while (Divisor != 0)
{
MSD = Input/Divisor;
switch (MSD)
{
case 0:
cout << "zero ";
break;
case 1:
cout << "one ";
break;
case 2:
cout << "two ";
break;
case 3:
cout << "three ";
break;
case 4:
cout << "four ";
break;
case 5:
cout << "five ";
break;
case 6:
cout << "six ";
break;
case 7:
cout << "seven ";
break;
case 8:
cout << "eight ";
break;
case 9:
cout << "nine ";
break;
}
Input = Input - (MSD * Divisor);
Divisor /= 10;
}
return 0;
}
你有沒有調試?????? –