1005 Spell It Right(20 分)

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

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 <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define wzf ((1 + sqrt(5.0)) / 2.0)
#define INF 0x3f3f3f3f
#define LL long long
using namespace std; const int MAXN = ; char s[MAXN];
int ans; stack <int> st;
map <int, string> mp; int main()
{
mp[] = "zero";
mp[] = "one";
mp[] = "two";
mp[] = "three";
mp[] = "four";
mp[] = "five";
mp[] = "six";
mp[] = "seven";
mp[] = "eight";
mp[] = "nine";
scanf("%s", &s); int len = strlen(s);
for (int i = ; i < len; ++ i)
ans += int(s[i] - '');
if (ans == )
{
printf("zero\n");
return ;
}
while (ans)
{
st.push(ans % );
ans /= ;
}
while (st.size() > )
{
cout <<mp[st.top()] <<" ";
st.pop();
}
cout <<mp[st.top()] <<endl;
st.pop();
return ;
}
 

1005 Spell It Right(20 分)的更多相关文章

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

  2. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...

  3. PAT Advanced 1005 Spell It Right (20 分)

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

  4. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) (switch)

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

  5. 【PAT甲级】1005 Spell It Right (20 分)

    题意: 给出一个非零整数N(<=10^100),计算每位之和并用英文输出. AAAAAccepted code: #include<bits/stdc++.h> using name ...

  6. 1005 Spell It Right (20 分)

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

  7. Day 006:PAT练习--1005 Spell It Right (20 分)

    上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...

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

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

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

随机推荐

  1. Halcon一日一练:创建AOI

    AOI:Area Of Interesting.感兴趣区域,即你要处理的区域. 一般情况,一整张图像,我们需要对局部进行操作,我们会选择一个我们需要处理的区域,对其进行处理,其他区域进行屏蔽.这个区域 ...

  2. go-json类

    package main import ( "encoding/json" "fmt" ) /* { "company":"itc ...

  3. SpringBoot-Mysql模板多数据源加载

    SpringBoot-Mysql模板多数据源加载 qq交流群: 812321371 微信交流群: MercyYao 简介 在 java 项目里常用到 mysql 多数据源操作.结合 springboo ...

  4. 微信小程序自定义弹窗(可通用)

    效果图 .wxml <cover-view class='mask' wx:if='{{isShow}}'> <cover-view class='modal'> <co ...

  5. 百万年薪python之路 -- 前端CSS基础介绍

    一. CSS介绍 CSS定义 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素,给HTML设置样式,让它更加美观. 语法结构 div{ color: green ...

  6. OracleService服务不见了|OracleServiceXE服务没有了

    服务里面本来应该有OracleService的(或者是Express版的OracleServiceXE),而服务列表没有此服务项,而启动数据库时出现: TNS监听程序当前无法识别连接描述符中请求的服务 ...

  7. OptimalSolution(3)--链表问题(2)进阶

    一.环形单链表的约瑟夫问题 二.判断一个链表是否为回文结构 三.将单向链表按某只划分成左边小.中间相等.右边大的形式 四.复制含有随机指针节点的链表 五.两个单链表相交的一系列问题 六.将单链表的每K ...

  8. 设计模式(十九)State模式

    在面向对象编程中,是用类表示对象的.也就是说,程序的设计者需要考虑用类来表示什么东西.类对应的东西可能存在于真实世界中,也可能不存在于真实世界中.对于后者,可能有人看到代码后会感到吃惊:这些东西居然也 ...

  9. Text 尺寸获取

    获取text在当前文本内容下应该尺寸: 宽度:text.preferredWidth 高度:text.preferredHeight

  10. SpringCloud之Feign负载均衡(四)

    整合Feign pom.xml <dependency> <groupId>org.springframework.cloud</groupId> <arti ...