当前位置: 代码迷 >> 综合 >> 【PAT甲级】1005 Spell It Right
  详细解决方案

【PAT甲级】1005 Spell It Right

热度:77   发布时间:2024-03-06 19:52:05.0

题目链接:1005 Spell It Right

#include <iostream>
using namespace std;
int main(){string s, english[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};int sum = 0;cin >> s;for(int i = 0; i < s.length(); i++) sum += s[i] - '0';s = to_string(sum);while(s.size()){cout << english[s[0]-'0'];s.erase(0,1);if(s.size()) cout << ' ';}
}

 

  相关解决方案