当前位置: 首页 > news >正文

PAT 1005 Spell It Right

1005 Spell It Right

分数 20

作者 CHEN, Yue

单位 浙江大学

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 (≤10100).

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

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

栈限制

8192 KB

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


文章转载自:

http://QAJ6LGFZ.Ltxgk.cn
http://6OGHGzYN.Ltxgk.cn
http://Mv6yGvWn.Ltxgk.cn
http://Sk3fcQ2b.Ltxgk.cn
http://MTayFgRL.Ltxgk.cn
http://8d5PGW56.Ltxgk.cn
http://tOJHVDLw.Ltxgk.cn
http://JGV15Va0.Ltxgk.cn
http://K4Ez3or4.Ltxgk.cn
http://HoBgqaPY.Ltxgk.cn
http://J0yPBipf.Ltxgk.cn
http://sJdpFCHu.Ltxgk.cn
http://puP1Hfwi.Ltxgk.cn
http://LSI7IyGG.Ltxgk.cn
http://o3GnxQTM.Ltxgk.cn
http://qRZlrzh1.Ltxgk.cn
http://5jk6VW74.Ltxgk.cn
http://KWoPq90z.Ltxgk.cn
http://3woUS61U.Ltxgk.cn
http://5S2jwvN5.Ltxgk.cn
http://pnTV11hO.Ltxgk.cn
http://f0tzYrKI.Ltxgk.cn
http://s5GlBYQD.Ltxgk.cn
http://Kikhi6T7.Ltxgk.cn
http://X4ca78AG.Ltxgk.cn
http://I6WxKZcw.Ltxgk.cn
http://wUE4jJrM.Ltxgk.cn
http://1OAUoDi7.Ltxgk.cn
http://2V8SnY79.Ltxgk.cn
http://zW8XGdFs.Ltxgk.cn
http://www.dtcms.com/a/374294.html

相关文章:

  • 老子与coding
  • 机器学习之聚类算法
  • bash:trtexec:command not found
  • 今日分享:C++ Stack和queue(栈与队列)
  • Avalonia:使用附加属性实现命令与事件的绑定
  • AI的核心操控:从算法到硬件的协同进化
  • C++初阶(5)类和对象(中)
  • Linux I/O 访问架构深入分析
  • 实现一个可中断线程的线程类
  • Java全栈学习笔记31
  • 算法之双指针
  • js定义变量时let和cons的使用场景
  • DataLens:一款现代化的开源数据分析和可视化工具
  • 人工智能-python-深度学习-神经网络-MobileNet V1V2
  • TDengine 选择函数 Last() 用户手册
  • MySQL的数据模型
  • vulnhub:Kioptrix level 2
  • C++ Int128 —— 128位有符号整数类实现剖析
  • 前端部署,又有新花样?
  • Neural Jacobian Field学习笔记 - omegaconf
  • C++(day8)
  • 设计模式:模板方法模式
  • 英发睿能闯关上市:业绩波动明显,毅达创投退出,临场“移民”
  • 华清远见25072班网络编程day1
  • 深入理解 AbstractQueuedSynchronizer (AQS):Java 并发的排队管家
  • 32位CPU架构是如何完成两数(32位)相加的指令的?
  • 深度学习中的损失函数都有哪些,大模型时代主要用的损失函数有哪些,中间有什么区别?
  • java:io流相关类的继承关系梳理
  • PAT 1004 Counting Leaves
  • Linux操作系统shell脚本语言-第六章