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 (<= 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 

简单的模拟类型题,没什么好说的。

代码

 1 #include <stdio.h>
 2 #include <string.h>
 3 
 4 int main()
 5 {
 6     char str[];
 7     char* const_str[] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
 8     while(gets(str)){
 9         int n = strlen(str);
         int i = ;
         int sum = ;
         for (;i<n;++i){
             sum = sum + str[i] - '';
         }
         sprintf(str,"%d",sum);
         n = strlen(str);
         printf("%s",const_str[str[]-'']);
         for(i=;i<n;++i){
             printf(" %s",const_str[str[i]-'']);
         }
         printf("\n");
     }
     return ;
 }

PAT 1005的更多相关文章

  1. PAT——1005. 继续(3n+1)猜想

    pat原题目:https://www.patest.cn/contests/pat-b-practise/1005 原题目: 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况 ...

  2. PAT 1005 Spell It Right

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

  3. PAT 1005 继续(3n+1)猜想 (25)(代码)

    1005 继续(3n+1)猜想 (25)(25 分) 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下 ...

  4. PAT 1005. 继续(3n+1)猜想 (25) JAVA

    当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对n=3进行验证的时候,我们需要计算3.5.8.4.2.1,则当我们对n=5.8.4.2进行验证的时候,就可以直接 ...

  5. PAT 1005. 继续(3n+1)猜想 (25)

    卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对n=3进行验证的时候, ...

  6. PAT——1005. 继续(3n+1)猜想 (25)

    卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对n=3进行验证的时候, ...

  7. PAT 1005 继续(3n+1)猜想

    https://pintia.cn/problem-sets/994805260223102976/problems/994805320306507776 卡拉兹(Callatz)猜想已经在1001中 ...

  8. PAT 1005 Spell It Right 字符串处理

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

  9. PAT 乙级 1005

    题目 题目地址:PAT 乙级 1005 题解 本题主要就在于将一个数的一系列计算结果不重复地存储起来并便于检索,考虑到STL中的集合有相似的特性,使用set可以有效地简化代码和运算. 过程如下: (初 ...

随机推荐

  1. 奋战5个小时解决诡异的PHP--“图像XX因其本身有错无法显示”的问题

    昨天终于将客户的一个网站迁移至虚拟主机上,满怀希望的敲入网址.唰的一声,网站很轻松的被打开了. 心里那个高兴啊~~~ 咦,怎么产品图片都没有显示出来.一块块都是空白.敲入img src对应的地址,看看 ...

  2. jQuery.autoComplete 多参数

    query 版本 1.3.2插件默认的 参数 是q 如果需要传递多个参数呢?$("#stylistname").autocomplete("/page/autostyli ...

  3. Ext入门学习系列(五)表格控件(2)

    上节学习了Ext中表格控件,从创建,到定义数据源.绑定显示,大体明白了一个基本的表格控件是怎么实现的.而我们用表格控件多用于从各种数据源接收数据并显示出来,并不是写死的.本章我们就不同数据源的不同实现 ...

  4. jQuery修改操作css属性实现方法

    在jquery中我们要动态的修改css属性我们只要使用css()方法就可以实现了,下面我来给各位同学详细介绍介绍. css()方法在使用上具有多样性,我们先来了解css()方法基本知识. css() ...

  5. 专门为公共部门和联邦机构所设计Microsoft Azure

    微软正式发布Microsoft Azure for Government,该云平台专门为公共部门和联邦机构所设计. 在2014年三月微软联邦执行官论坛上宣布的Microsoft Azure for G ...

  6. rtems总结

    rtems 历史背景及现状 常用的api 和参数介绍 rtems_interrupt_enable rtems_interrupt_is_in_progress rtems_cache_flush_r ...

  7. Struts2 url传递中文出现乱码

    项目所有的编码都改为了utf-8.在tomcat的 server.xml中修改下面这段 <Connector port="8080" protocol="HTTP/ ...

  8. [Objective-c 基础 - 2.8] category分类/类别/类目

    A.给某个类扩充方法(不改变原来的类) 例如,给类Person加上名为Simon的category,加上一个-study方法 使用()注明 Person+Simon.h @interface Pers ...

  9. [Objective-c 基础 - 2.7] 构造方法、重写init方法

    A.id 万能指针,可以指向任何对象,实质是NSObject的指针,使用的时候不用加上*   B.NSObject中得类方法new 1.完整地创建一个可用对象步骤 (1)分配存储空间 + alloc ...

  10. 爬去知乎百万用户信息之UserTask

    UserTask是获取用户信息的爬虫模块 public class UserManage { private string html; private string url_token; } 构造函数 ...