https://www.patest.cn/contests/pat-a-PRactise/1005
#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <cstdlib>using namespace std;string SpellRight(int i) { switch (i) { case 0:return "zero"; break; case 1:return "one"; break; case 2:return "two"; break; case 3:return "three"; break; case 4:return "four"; break; case 5:return "five"; break; case 6:return "six"; break; case 7:return "seven"; break; case 8:return "eight"; break; } return "nine";}int main() { char N[101]; cin >> N; int temp = 0; int len = strlen(N); string ma; for (int i = 0; i < len; i++) { temp += (N[i] - '0'); } ma = SpellRight(temp%10); //five //12345 temp /= 10; // while (temp) { ma = " " + ma; ma = SpellRight(temp % 10) + ma; temp /= 10; } cout << ma << endl; system("pause"); return 0;}新闻热点
疑难解答