题目描述

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.

输入描述:

Each input file contains one test case. Each case occupies one line which contains an N (<= 10100).

输出描述:

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.

输入例子:

12345

输出例子:

one five

太简单了。。。。
 #include <iostream>
#include <string>
#include <vector> using namespace std; int main()
{
vector<string>words = { "zero","one","two","three","four","five","six","seven","eight","nine","ten" };
string num;//不能用数字类型存储,会导致溢出的
cin >> num;
int sum = ;
for (auto a : num)
sum += a - '';
num = to_string(sum);
cout << words[num[] - ''];
for (int i = ; i < num.length(); ++i)
cout << " " << words[num[i] - ''];
cout << endl;
return ;
}

PAT甲级——A1005 Spell It Right的更多相关文章

  1. PAT 甲级 1005 Spell It Right (20 分)

    1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...

  2. PAT 甲级 1005 Spell It Right (20)(代码)

    1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...

  3. PAT 甲级 1005 Spell It Right

    https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative i ...

  4. PAT 甲级 1005. Spell It Right (20) 【字符串】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...

  5. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  6. PAT甲级代码仓库

    大道至简,知易行难.希望能够坚持刷题. PAT甲级真题题库,附上我的代码. Label Title Score Code Level 1001 A+B Format 20 1001 * 1002 A+ ...

  7. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  8. PAT甲级1131. Subway Map

    PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...

  9. PAT甲级1127. ZigZagging on a Tree

    PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...

随机推荐

  1. Jmeter----请求依赖之边界值提取器

    填写左边界和右边界 引用变量名就是要存储的变量名词

  2. Jmeter----参数化之csv文件

    用户编码:一般不用填写,如果有中文的时候,需要填写,填写utf-8就可以 变量名词:是指的把数据保存在什么变量里面,其他的默认就好了 Http请求和用户参数设置的一样

  3. C++ static静态成员变量在类中仅仅是声明

    今天写代码时看到: 图1的3个静态成员变量在类中仅仅是声明,没有定义以及分配内存:必须在类外,图中就是cpp中,定义分配内存,才能使用

  4. SQLserver执行命令

    方法一:xp_cmdshell  exec master..xp_cmdshell "whoami"默认执行是关闭 EXEC sp_configure 'show advanced ...

  5. The linux command 之定制提示符

    一.提示符分解 默认提示符如下所示: [me@linuxbox ~]$ 可以看出它包括我们的用户名.主机名.当前工作目录.提示符是由PS1变量定义的. [me@linuxbox ~]$ echo $P ...

  6. CSIC_716_20191116【常用模块的用法 time ,datetime, random, os, sys, hashlib】

    import time import datetime import os import sys import random import hashlib time模块 时间戳(Timestamp) ...

  7. canvas基础用法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. Java-Maven-pom.xml-project-build-plugins:plugins

    ylbtech-Java-Maven-pom.xml-project-build-plugins:plugins 1. platform返回顶部 1.maven-compiler-plugin < ...

  9. (一)通过JAVA连接SAP (sapjco3.jar在Windows和MacOS上的配置)

    (一)通过JAVA连接SAP调用接口 (sapjco3.jar在Windows和MacOS上的配置) 一.sapjoc3.jar获取 由于sap官网提供的链接需要合作公司提供账号密码,如果商用请索要正 ...

  10. JS 内置对象 String对象

    JS内置对象   String对象:字符串对象,提供了对字符串进行操作的属性和方法.   Array对象:数组对象,提供了数组操作方面的属性和方法.   Date对象:日期时间对象,可以获取系统的日期 ...