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 (≤).
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<string>
#include<stdlib.h>
#include<vector>
using namespace std;
char str[][] = { "zero","one","two","three","four","five","six","seven","eight","nine" };
int main()
{
int digit[] = { };
char c;
int num = ;
c = getchar();
while (c!='\n')
{
num += c - '';
c = getchar();
}
int i=;
if (!num)
{
printf("%s", str[]);
return ;
}
while (num)
{
digit[i++] = num % ;
num /= ;
}
while (--i)
printf("%s ", str[digit[i]]);
printf("%s", str[digit[i]]);
return ;
}
1005 Spell It Right (20 分)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 【PAT甲级】1005 Spell It Right (20 分)
题意: 给出一个非零整数N(<=10^100),计算每位之和并用英文输出. AAAAAccepted code: #include<bits/stdc++.h> using name ...
- Day 006:PAT练习--1005 Spell It Right (20 分)
上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...
- 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 ...
- 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 (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏
1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
随机推荐
- 第三篇:Linux的基本操作与文件管理(纯命令行模式下)(下)
接上篇介绍完软件的管理(查询.删除.安装)之后,本篇将介绍Linux的文件和目录的管理. 如何浏览Linux的目录(文件夹),就像Windows一样,我们平时需要打开各个目录,去里面找一找曾经悄悄存储 ...
- CVPR 2020 三篇有趣的论文解读
作者 | 文永亮 学校 | 哈尔滨工业大学(深圳) 研究方向 | 视频预测.时空序列预测 目录 AdderNet - 其实不需要这么多乘法 Deep Snake for Real-Time Insta ...
- 第一个爬虫经历----豆瓣电影top250(经典案例)
因为要学习数据分析,需要从网上爬取数据,所以开始学习爬虫,使用python进行爬虫,有好几种模拟发送请求的方法,最基础的是使用urllib.request模块(python自带,无需再下载),第二是r ...
- js 渐变运动框架
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- sessionStorage localStorage 和 cookie 之间的区别转
sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可以方便的在web请求之间保存数据.有了本地数据,就可以避免数据在浏览器和服务器间不必 ...
- Flutter配置环境报错“PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”
背景:最近看了很多Flutter漂亮的项目,想要尝试一下.所有环境都搭建好之后,按照文档一步一步配置(抄袭),但始终报如下图错误. PKIX path building failed: sun.sec ...
- Python-列表做的购物车小程序
一.流程为,输入你有多少钱,然后循环购买商品,输入‘q’ 退出程序 goods=[['苹果',6500],['华为',4999],['小米',2999],['oppo',3599]] #初始化列表,填 ...
- 使用@property 添加width 和 height 属性
@property Python内置的@property装饰器就是负责把一个方法变成属性调用的: class Screen(object): def isint(self,px): if not is ...
- 逻辑回归和sigmoid函数分类
逻辑回归和sigmoid函数分类:容易欠拟合,分类精度不高,计算代价小,易于理解和实现 sigmoid函数与阶跃函数的区别在于:阶跃函数从0到1的跳跃在sigmoid函数中是一个逐渐的变化,而不是突变 ...
- mysql打开general log的办法
mysql打开general log的办法 mysql打开general log之后,所有的查询语句都可以在general log 文件中以可读的方式得到,但是这样general log文件会非常 ...