部分正确?
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<string> format_numbers{ "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
string n = "3";
//cin >> n;
unsigned short sum = 0;
for (auto &r : n)
{
sum = sum + static_cast<int>(r) - 48;
}
cout << sum << endl;
string out;
if (0 == sum)
{
out = string(format_numbers[0]);
}
else
{
while (sum % 10)
{
if (0 == out.length())
out = string(format_numbers[sum % 10]);
else
out = string(format_numbers[sum % 10]) + " " + out;
sum = sum / 10;
}
}
cout << out;
cin.ignore();
return 0;
}
网友评论