当前位置:网站首页>1005 Spell It Right (20分)
1005 Spell It Right (20分)
2022-08-09 10:48:00 【Cutecumber】
1005 Spell It Right (20分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.
Input Specification:
Each input file contains one test case. Each case occupies one line which contains an N (≤10^100).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
12345
Sample Output:
one five
#include<iostream>
#include<string>
using namespace std;
//string用法 http://c.biancheng.net/view/400.html
int main(){
string digits;
char ch;
char table[10][10] = {
"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int sum=0;
string result;
cin >> digits;
while(digits.size()>0){
ch = digits[0];
digits.erase(0,1);
sum += ch-'0';
}
result = to_string(sum);
ch = result[0];
result.erase(0,1);
cout << table[ch-'0'];
while(result.size()>0){
ch = result[0];
result.erase(0,1);
cout << ' ' << table[ch-'0'];
}
return 0;
}
边栏推荐
- unix环境编程 第十四章 14.4 I/O多路转接
- Input and output of cnn
- tensorflow实现线性方程的参数调整
- autogluon安装,使用指南,代码
- 使用cpolar远程连接群晖NAS(创建临时链接)
- 日期工具类
- Mysql多表查询
- [Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in
- torch.stack()的官方解释,详解以及例子
- How to quickly get through the mirror release process?
猜你喜欢
pytorch widedeep文档
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in
人物 | 从程序员到架构师,我是如何快速成长的?
arcgis制图之天地图符号样式配置
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
Cluster understanding
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization Paper Reading
MySQL索引的B+树到底有多高?
编解码(seq2seq)+注意机制(attention) 详细讲解
ESIM(Enhanced Sequential Inference Model)- 模型详解
随机推荐
【 original 】 VMware Workstation implementation Openwrt soft routing, the ESXI, content is very detailed!
强化学习 (Reinforcement Learning)
Dialogue with the DPO of a multinational consumer brand: How to start with data security compliance?See you on 8.11 Live!
tensor.eq() tensor.item() tensor.argmax()
Product Quantization (PQ)
百度云大文件网页直接下载
TensorFlow:NameError: name ‘input_data’ is not defined
【报错记录】解决华擎J3455-ITX不插显示器无法开机的问题
深度学习--自编码器(AutoEncoder)
OpenSSF's open source software risk assessment tool: Scorecards
爬虫实例,获取豆瓣上某部电影的评论
Unix Environment Programming Chapter 15 15.3 Functions popen and pclose
1004 成绩排名 (20 分)
如何在gazebo进行 joint的转动控制
日期工具类
[华为云在线课程][SQL语法分类][数据操作][学习笔记]
史上最小白之《Word2vec》详解
机器学习-逻辑回归(logistics regression)
1002 写出这个数 (20 分)
BERT预训练模型(Bidirectional Encoder Representations from Transformers)-原理详解