1005. Spell It Right (20)

简介: #include using namespace std;int main(int argc, const char * argv[]) { string s; cin >> s; int sum = 0, len = (int)s.

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int sum = 0, len = (int)s.length();
    
    for (int i = 0; i < len; i++) {
        sum += s[i] - '0';
    }
    
    string sp = to_string(sum);
    string num[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    
    cout << num[sp[0] - '0'];
    for (int i = 1; i < sp.length(); i++) {
        cout << ' ' << num[sp[i] - '0'];
    }
    
    cout << endl;
   
    return 0;
}


目录
相关文章
|
2月前
|
Java Spring
allowedOrigins cannot contain the special value "*"
allowedOrigins cannot contain the special value "*"
31 0
|
3月前
|
安全
Warning: Don’t paste code into the DevTools Console that you don’t understand or haven’t reviewed yo
Warning: Don’t paste code into the DevTools Console that you don’t understand or haven’t reviewed yo
|
5月前
|
编译器 C语言
gcc编译警告:warning: suggest parentheses around assignment used as truth value
gcc编译警告:warning: suggest parentheses around assignment used as truth value
145 0
|
10月前
又被ESLint 调戏了!!! ESLint:Newline required at end of file but not found. eslint(eol-last) [12, 22]
又被ESLint 调戏了!!! ESLint:Newline required at end of file but not found. eslint(eol-last) [12, 22]
|
10月前
|
前端开发 JavaScript
brackets
brackets
50 0
|
算法 Python
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
LeetCode 1160. 拼写单词 Find Words That Can Be Formed by Characters
|
Android开发
The word is not correctly spelled问题
The word is not correctly spelled问题
218 0
The word is not correctly spelled问题
|
算法 Linux 测试技术
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
230 0
【论文阅读】(2014)Combinatorial Benders’ Cuts for the Strip Packing Problem
|
数据库
When Tech Meets Love – Smarter Ways to NOT be Single
It’s that time of year again. Single’s Day (a.k.a Double 11) is just around the corner, people buying gifts for loved ones.
1617 0
When Tech Meets Love – Smarter Ways to NOT be Single
Brackets安装emmit
https://www.cnblogs.com/yaosutu/p/7352642.html lib里面需要caniuse.json才能生效,具体看上面的文章
790 0