#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
int sum = 0;
string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};
for (int i = 0; i < s.length(); i++)
sum += (s[i] - '0');
string num = to_string(sum);
for (int i = 0; i < num.length(); i++) {
if (i != 0) cout << " ";
cout << str[num[i] - '0'];
}
return 0;
}
当用dev c++编译时会报 [Error] 'to_string' was not declared in this scope
当用code::Blocks编译时会报 to_string' was not declared in this scope
原因一样,均是因为编译器不支持C++11标准,所以解决方法就是使其能够支持该标准。
具体解决方案如下:
对于dev-C++
tool-Compiler Options
勾选Add the following commands when calling the comoiler选项,然后在输入框中输入:-std=c++11。即可!
对于Code::Blocks
setting-compiler
如图,勾选C++11标准即可!