题目描述:

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. HDU 1251 统计难题 (Trie树模板题)

    题目链接:点击打开链接 Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单 ...

  2. 第3章 JDK并发包(三)

    3.2 线程复用:线程池 一种最为简单的线程创建和回收的方法类似如下代码: new Thread(new Runnable() { @Override public void run() { // d ...

  3. centos下升级php到5.6

    今天正好用空把php环境升级到5.6版本,首先我之前的环境是源码包编译的lnmp环境 首先到php官方网站上下载一个php5.6的tar包,放到机器上面后,开始安装,安装前先将nginx,mysql, ...

  4. [redis读书笔记] 第一部分 数据结构与对象 链表

    二 链表 1.链表节点使用ListNode结构,是一个双向的链表,同时,还实现了一个控制所有ListNode的结构list: typedef struct listNode { // 前置节点 str ...

  5. hbase架构和读写过程

    转载自:https://www.cnblogs.com/itboys/p/7603634.html 在HBase读写时,相同Cell(RowKey/ColumnFamily/Column相同)并不保证 ...

  6. 大延时情况tcp和udp测试

    环境搭建 使能Ubuntu的IPv6转发功能 root@yanhc-Aspire-4738G:/home/yanhc# cat /proc/sys/net/ipv4/ip_forward root@y ...

  7. mongoDB常用命令与安全加固

    一.介绍 MongoDB 是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系 ...

  8. zabbix 自定义监控项报警给单独的人

    需求就是某个交换机的流量达到某个值后需要报警,但报警的内容不是发给所有的人,而是只发给特定的一个人,而其他的报警信息不能让他收到,他只能收到这一个报警项的报警 1:创建好用户定义好手机号 2:新增加一 ...

  9. vue路由--动态路由

    前面介绍的路由都是路径和组件一对一映射的 有时候需要多个路径映射到一个组件,这个组件根据参数的不同动态改变,这时候需要用到动态路由 动态路由这样定义路由路径: path: '/foo/:id'--可以 ...

  10. Linux监控-历史细项数据回溯

    Linux监控数据回溯 网络服务监控 应用场景: lvs 后端内网端机器网络波动监控: nginx 80.443端口连接监控: mysql 连接监控 以上为抛砖引玉,根据环境安装到监控工具(open ...