本题要用字符串或者字符数组保存输入,不然会越界。
还有就是本题中int转string使用了stringstream。
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string eng[10] = {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine"};
int main()
{
string s;
cin>>s;
int total = 0;
for(string::iterator it = s.begin(); it != s.end(); it++)
total += *it - '0';
stringstream ss;
ss<<total;
string o;
ss>>......
阅读全文