#include <iostream>
#include <string>
using namespace std;
int main()
{
string onesPlace[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine",};
string thoseCrazyTeens[] = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen",};
string tensPlace[] = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety",};
float userInput = 0;
bool flag = true;
cout << "Please input your check amount. " << endl;
while (flag == true)
{
cin >> userInput;
if (userInput > 100000)
{
cout << "That number is too big! Try again. " << endl;
flag = true;
}
else
{
flag = false;
}
}
int partOne = userInput;
return 0;
}
目前我正在開發這個程序,它接受用戶輸入(支票金額)並將其從數值轉換爲單詞達到100000.我想要做的一個例子是344.47美元:檢查字數?
三百四十四和67/100。
我已經得到了我需要的單詞的字符串值(數百和數千可以稍後超過一定的數值),現在我想弄清楚如何得到小數點後的小數。如果我使用mod,它並不總是準確的。
之後,是否有一種簡單的方法可以在沒有太多if語句的情況下通過1到20來吹?
合併你的第一個2個單詞的數組,並在開頭添加「零」。數字索引將是數組中的單詞,然後 – cppguy