1005.Spell It Right

来源:互联网 发布:武汉mac口红专柜在哪里 编辑:程序博客网 时间:2024/05/17 07:16

【题意】

把给的数字每一位加起来,然后用英文表示结果的每一位


【思路】
按题意直接算即可

#include <iostream>#include <string>using namespace std;string number[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};void spell(int num){if(num/10>0){spell(num/10);cout << " ";}cout << number[num%10];}int main(){string str;int sum=0;cin >> str;for(int i=0; i<str.length(); i++){sum = sum+str[i]-'0';}spell(sum);system("pause");return 0;}


0 0
原创粉丝点击