题目描述:

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

问题分析:此题过于弱智,没有思路,干就完了,奥里给!

代码:
 #include <iostream>
#include <cstring>
#include <string>
using namespace std; const string x[]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main(){
char ch[];
int a[],l,sum=;
cin.getline(ch,);
for (int i=;i<=;i++){
if (isdigit(ch[i])){
sum+=ch[i]-'';
}
else{
break;
}
}
for (int i=;;i++){
a[i]=sum % ;
sum/=;
if (sum==){
l=i+;
break;
}
}
for (int i=l-;i>;i--){
cout << x[a[i]] << " ";
}
cout << x[a[]];
return ;
}

PTA 1005 Spell It Right的更多相关文章

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

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

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

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

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

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

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

  8. 1005 Spell It Right

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

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

随机推荐

  1. 自学Java第二章——《Java的基础语法》

    2.1 标识符 简单的说,凡是程序员自己命名的部分都可以称为标识符. 即给类.变量.方法.包等命名的字符序列,称为标识符. 1.标识符的命名规则 (1)Java的标识符只能使用26个英文字母大小写,0 ...

  2. 位运算在状态压缩DP中的应用

    一.判断一个数字X的i位是不是1 方法:   << (i-)) & x > )  原理: 1左移(i-1)位,相当于制造了一个就i位上是1其他位都是0的一个二进制数.将这个数 ...

  3. RestTemplate工具类根据服务名发送请求

    要使用RestTemplate 根据服务名发送请求的话需要 使用  @LoadBalanced  这个注解,用了这个注解的RestTemplate就不用使用  ip 来请求了,首先要创建一个配置类 i ...

  4. Codeforces 1050D Three Religions (dp+序列自动机)

    题意: 给一个1e5的串str,然后有三个起始空串,不超过1000次操作,对三个字符串的一个尾部加一个字符或者减一个字符,保证每个字符不会超过250 每次操作之后询问你这三个串是不是可以组成str的子 ...

  5. HDU 6186 CS Course (连续位运算)

    CS Course Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  6. SpringBoot之ApplicationRunner接口和@Order注解

    我们在开发中可能会有这样的情景.需要在容器启动的时候执行一些内容.比如读取配置文件,数据库连接之类的.SpringBoot给我们提供了ApplicationRunner接口来帮助我们实现这种需求.该接 ...

  7. 【python-leetcode713-双指针】乘积小于k的子数组

    问题描述: 给定一个正整数数组 nums. 找出该数组内乘积小于 k 的连续的子数组的个数. 示例 1: 输入: nums = [10,5,2,6], k = 100输出: 8解释: 8个乘积小于10 ...

  8. JDK14都要问世了,你还在用JDK8吗

    Java开发工具包(JDK)14已进入发布候选阶段,总体功能基本已确定.计划中的标准Java升级将具有新功能,例如JDK Flight Recorder事件流,模式匹配和开关表达式. JDK 14计划 ...

  9. 浅谈.NET中AppDomain的理解

    一.走进.NET AppDomain 天哪,.NET Framwork的CLR真是巧妙呢!随着越来越多的对.Net底层编程的了解,一些诸如架构,处理过程的复杂难懂的细节完全的让我叹服,所以呢,再次错过 ...

  10. Debug使用

    目录 Debug使用 Debug使用