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

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

这是签到题目把?
import java.util.*;

public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
sc.close();
int res = ;
for(int i=;i<str.length();i++)
res+=Integer.valueOf(str.charAt(i)-);
String result = String.valueOf(res);
for(int i=;i<result.length();i++) {
switch(result.charAt(i)) {
case '':
System.out.print("zero");
break;
case '':
System.out.print("one");
break;
case '':
System.out.print("two");
break;
case '':
System.out.print("three");
break;
case '':
System.out.print("four");
break;
case '':
System.out.print("five");
break;
case '':
System.out.print("six");
break;
case '':
System.out.print("seven");
break;
case '':
System.out.print("eight");
break;
case '':
System.out.print("nine");
break;
}
if(i!=result.length()-) System.out.print(" ");
}
}
}

1005 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

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

  3. 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 ...

  4. 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 th ...

  5. 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 ...

  6. PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏

    1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...

  7. PTA 1005 Spell It Right (20)(20 分)水题

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

  8. 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 the ...

  9. 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 ...

随机推荐

  1. leetcode-8-pointer

    void deleteNode(ListNode* node) { *node = *node->next; }

  2. socketserver源码剖析

    作者:人世间链接:https://www.jianshu.com/p/357e436936bf來源:简书简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处 BaseServer 和 B ...

  3. 03011_HttpServletRequest

    1.HttpServletRequest概述 (1)我们在创建Servlet时会覆盖service()方法,或doGet()/doPost(),这些方法都有两个参数,一个为代表请求的request和代 ...

  4. [python] 求大神解释下 面向对象中方法和属性

    面向对象中 类方法 实例方法 类属性 实例属性该如何理解呢?

  5. Diango 一——URL

    内容概要 1.web框架初识 2.MTV模式 3.Django创建流程和命令行工具 4.配置文件  settings 5.视图函数  views 6.路由系统  URL 7.模板系统  templat ...

  6. [POJ 1007] DNA Sorting C++解题

        DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 77786   Accepted: 31201 ...

  7. wamp搭建的服务器远程无法访问的问题

    最近在一台win2003的服务器上安装配置好了wamp,服务启动正常,服务器本机访问localhost正常,但是我自己的电脑(相对于服务器来说是远程机器)访问时,提示显示You don't have ...

  8. Spring core resourc层结构体系及JDK与Spring对classpath中资源的获取方式及结果对比

    1. Spring core resourc层结构体系 1.1. Resource相关结构体系 1.2. ResourceLoader相关体系 2. JDK与Spring对classpath中资源的获 ...

  9. 【转】javascript操作Select标记中options集合

    先来看看options集合的这几个方法:options.add(option)方法向集合里添加一项option对象:options.remove(index)方法移除options集合中的指定项:op ...

  10. linux 系统时间调整

    linux的硬件时间是从COMS中读取的. 系统时间是由操作系统维护的. 先查看时区是否正确 (东八区 +8) #date -R 选择时区: #tzselect 修改了系统时间,还应该跟硬件时间进行同 ...