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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Django之模型---ORM 多表操作
多表操作 创建表模型 from django.db import models # Create your models here. class Author(models.Model): nid = ...
- 转:跟我一起写Makefile (PDF重制版)
原文地址:http://seisman.info/how-to-write-makefile.html 其它一些问题 不妨看一下:http://blog.csdn.net/huyansoft/art ...
- stm32之Cortex系统定时器(SysTick)
转载自:http://www.21ic.com/app/mcu/201811/781135.htm SysTick时钟,俗称“嘀嗒定时器”,它能按设定的时间产生一次中断.控制工程代码中随处可见形如 ...
- POJ:2955-Brackets(经典:括号匹配)
传送门:http://poj.org/problem?id=2955 Brackets Time Limit: 1000MS Memory Limit: 65536K Description We g ...
- PAT Basic 1080
1080 MOOC期终成绩 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的在线编程作业分 ...
- PAT Basic 1075
1075 链表元素分类 给定一个单链表,请编写程序将链表元素进行分类排列,使得所有负值元素都排在非负值元素的前面,而 [0, K] 区间内的元素都排在大于 K 的元素前面.但每一类内部元素的顺序是不能 ...
- Centos启动时停止在登录界面但不显示登录信息(一直在转圈)
进入单用户模式 执行 iscsiadm -m node -o delete,然后reboot
- 深入理解Python中的进程
1.进程的概念什么是进程—>CPU在同一时刻只能处理一个任务,只是因为cpu执行速度很快. cpu在各个任务之间来回的进行切换. 进程的概念:正在进行的一个过程或者说一个任务,而负责执行任务的则 ...
- 异常 ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang.test.MyView
发现自定义view时出现ndroid.view.InflateException: Binary XML file line #8: Error inflating class com.ouyang. ...
- activity-alias
activity-alias标签,它有一个属性叫android:targetActivity,这个属性就是用来为该标签设置目标Activity的,或者说它就是这个目标Activity的别名.至此我们已 ...