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 <cstring>
using namespace std;char num[10][15] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
char cc[200], nn[200];
int sum = 0;
int ct = 0;int main()
{scanf("%s", cc);int len = strlen(cc);  //字符串长度for(int i = 0; i < len; i++){sum += cc[i]-'0';  //转数字}if(sum == 0) printf("%s", num[0]);while(sum != 0){nn[ct++] = (sum%10) + '0';sum /= 10;}for(int i = ct - 1; i >= 0; i--){if(i!=0)printf("%s ",num[nn[i]-'0']);elseprintf("%s",num[nn[i]-'0']);}return 0;
}

注意点:

1.字符转数字 -‘0’  ,数字转字符 +‘0’

PAT甲级 -- 1005 Spell It Right (20 分)相关推荐

  1. 【PAT】1005 Spell It Right (20 分)——字符串处理

    //要么处理字符串,要么就数字分解,都想到了没有有效组合 //我的解法1:加法结果还是int,最后逆序分解数字,按序插入#include <iostream> #include <s ...

  2. 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 al ...

  3. PAT甲级1005 Spell It Right :[C++题解]字符串处理

    文章目录 题目分析 题目链接 题目分析 ac代码 #include<bits/stdc++.h> using namespace std;const int N =110;string n ...

  4. PAT甲级 1027 Colors in Mars (20分)

    1027 Colors in Mars (20分) 题目链接:PAT A 1027 题目大意:给出三个十进制数,都是在[0-168]范围内,要求将他们转化为13进制后按顺序输出. 思路分析:非常简单的 ...

  5. PAT甲级 -- 1148 Werewolf - Simple Version (20 分)

    Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and th ...

  6. 1005 Spell It Right (20 分)——13行代码Ac

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given a non-negative integer N, your task is to compute the sum o ...

  7. 【PAT甲级 StringBuilder的使用】1005 Spell It Right (20 分) Java版 7/7通过

    题目 挺简单的,是个水题 坑 & 心得 一开始switch (i)忘了写case 0的情况,导致两个测试点没通过,不过很快就发现了 int 类型的 sum 转换为 str 的方式:用空字符串拼 ...

  8. 【PAT (Advanced Level) Practice】1005 Spell It Right (20 分)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<string> #incl ...

  9. 【PAT甲级 约会】1061 Dating (20 分) C++ 全部AC

    题目 这个题要注意的细节很多.因为一个星期有七天,一天有24小时,所以要注意字母范围这个隐藏条件,不符合条件的字母要跳过. 还要注意:第二次查找,要接着第一次找到的位置开始找.这个有点坑,题目里没说明 ...

最新文章

  1. php排版word文档试卷,word选择题选项排版
  2. L1正则化与数据分布的关系
  3. IOS中货币高精度要求使用NSDecialNumber、
  4. 设计模式学习笔记——命令模式
  5. 网站导航颜色停留_提高网站流量的方法有哪些?
  6. 再立阶段目标 09.10.26
  7. 200行Python代码实现的2048小游戏
  8. 2021年2 分以上优秀护理相关SCI 期刊汇总
  9. 测度论与概率论基础学习笔记1——1.1 集合及其运算
  10. stm32h750电路_STM32H750开发板
  11. firefox主页被360篡改_IE浏览器主页被劫持,如何解决主页被篡改问题?
  12. EDI的含义及其重要性
  13. 21.pgsql中的执行计划explain
  14. Oauth认证-新浪微博开发(上)
  15. 24小时学会,从抓包到接口测试
  16. 手把手教你构建 C 语言编译器(8)- 表达式
  17. PowerBuilder 8/9 与 SCC的集成(1)
  18. java怎么实现按键音_实例:使用Javascript制作声音按钮
  19. 谭浩强c++第9章 题9商店销售某一商品,商店每天公布统一的折扣(discount)。同时允许销售人员在销售时灵活掌握售价(price),在此基础上,对一次购10件以上者,还可以享受9.8折优惠。
  20. Xamarin.Android入门

热门文章

  1. 网络编程释疑之:TCP协议的“流”特性
  2. WebRTC 的 AudioSource/AudioTrack
  3. 慌!还不了解Java中的分支预测?!
  4. 集群管理工具KafkaAdminClient——改造
  5. 研究人员的AI技术能够实时匹配活页乐谱与MIDI音频
  6. 堡垒之夜一年内增1亿玩家、YouTube为支持AV1的8K电视提供8K内容、Elon Musk要过极简生活等...
  7. 360视频云Web前端HEVC播放器实践剖析
  8. 剑指offer之61-66题解
  9. Java多线程之Synchronized和Lock的区别
  10. 腾讯郭振宇:腾讯云发布云IoT全栈产品矩阵,详解6大产品及3大案例