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. 数据结构和算法(What Why How)

    数据结构和算法是什么? 从广义上讲,数据结构就是指一组数据的存储结构.算法就是操作数据的一组方法. 从狭义上讲,是指某些著名的数据结构和算法,比如队列.堆.栈.二分查找.动态规划等. 数据结构和算法有 ...

  2. CF 219 D:Choosing Capital for Treeland(树形dp)

    D. Choosing Capital for Treeland 链接:http://codeforces.com/problemset/problem/219/D   The country Tre ...

  3. luogu3383 【模板】线性筛素数

    如果prime[i]是k的因子,那么[k * (在prime[i]以后的质数)]等于[prime[i]*(k/prime[i])*(这个质数)],一定被筛过了,所以这里可以break. #includ ...

  4. python week08 并发编程之多线程--实践部分

    一. threading模块介绍 multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性,因而不再详细介绍 官网链接:https://docs.pytho ...

  5. MySQL 表数据的导入导出

    数据导出 1.  使用 SELECT ...INTO OUTFILE ...命令来导出数据,具体语法如下. mysql> SELECT * FROM tablename INTO OUTFILE ...

  6. [python学习篇][书籍学习][python standrad library][内建函数]之[list,open,len,pow,range,

    Python 解释器内置了一些函数,它们总是可用的.这里将它们按字母表顺序列出.     Built-in Functions     abs() divmod() input() open() st ...

  7. 项目记事【多线程】:关于 SimpledDateFormat 的多线程问题

    背景: 最近项目引入了 SonarLink,解决代码规范的问题,在检查历史代码的时候,发现了一个问题. 先看代码: public class DateUtil { private static fin ...

  8. 用JS去掉前后空格或中间空格大全

    1.  去掉字符串前后所有空格: -- js实现trim功能 //去除字符串前后所有空 function Trim(str) { return str.replace(/(^\s*)|(\s*$)/g ...

  9. 本博客由CSDN迁移而来,以前的博文可能显示不正常

    如题,原博客地址 http://blog.csdn.net/vicjiao 或点击右侧友链

  10. 报错:java.lang.IllegalStateException

    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call '“refresh”' be ...