当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
批量转换经纬度的网页实现方法
华为VRRP+MSTP联动接口检测实验案例
研发需求的验收标准应该怎么写? | 敏捷实践
prometheus接入mysqld_exporter
聚类了解
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
情感分析SowNLP词库
【原创】解决阿里云oss-browser.exe双击没反应打不开,提供一种解决方案
Dialogue with the DPO of a multinational consumer brand: How to start with data security compliance?See you on 8.11 Live!
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in
随机推荐
VBA实战(11) - 工作表(Sheet) 操作汇总
实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
tensorflow和numpy对应的版本,报FutureWarning: Passing (type, 1) or ‘1type‘ as a synonym of type is deprecate
[Original] Usage of @PrePersist and @PreUpdate in JPA
2022强网杯WP
985毕业,工作3年,分享从阿里辞职到了国企的一路辛酸和经验
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in
Unix System Programming Chapter 15 15.2 Pipes
人物 | 从程序员到架构师,我是如何快速成长的?
深度学习--循环神经网络(Recurrent Neural Network)
备战金三银四:如何成功拿到阿里offer(经历+面试题+如何准备)
获取指定年度所有周的工具类
How tall is the B+ tree of the MySQL index?
tensorflow实现线性方程的参数调整
autogluon安装,使用指南,代码
Product Quantization (PQ)
1003 我要通过! (20 分)
cnn的输入输出
jmeter BeanShell 后置处理器
The complete grammar of CSDN's markdown editor