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

题意:

给一个最多100位的数字,把各位上的数求和,把结果各位上的数字翻译成英文输出。

思路:

暴力。

 #include <iostream>
#include <set>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;
#define inf 0x7f7f7f7f char s[];
string spell[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int str[]; int main()
{
scanf("%s", s);
int n = strlen(s);
int ans = ;
for(int i = ; i < n; i++){
ans += s[i] - '';
}
int l = ;
if(ans == ){
str[l++] = ;
}
while(ans){
str[l++] = ans % ;
ans /= ;
} cout<<spell[str[l - ]];
for(int i = l - ; i >= ; i--){
cout<<" "<<spell[str[i]];
}
cout<<endl; return ;
}

PAT甲1005 Spell it right【字符串】的更多相关文章

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

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

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

  4. PAT 甲级 1005. Spell It Right (20) 【字符串】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...

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

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

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

  7. PAT 甲级 1005 Spell It Right

    https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336 Given a non-negative i ...

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

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

随机推荐

  1. [原]C# 常用函数统计

    1.获取MD5 string MD5Compute(string strPwd) { MD5CryptoServiceProvider m5 = new MD5CryptoServiceProvide ...

  2. C# winform pictureBox如何突出显示,放大并给pictureBox边框变色

    PictureBox old = null; private void pictureBox2_Click(object sender, EventArgs e) { PictureBox p = ( ...

  3. 使用srvany.exe把程序安装成windows服务的方法

    http://mazhihui.iteye.com/blog/1294431 srvany.exe是什么? srvany.exe是Microsoft Windows Resource Kits工具集的 ...

  4. Linux+Redis实战教程_day02_2、redis简述及安装与启动

    2. redis简述及安装 关系型数据库(SQL): Mysql,oracle 特点:数据和数据之间,表和字段之间,表和表之间是存在关系的 例如:部门表 001部门,   员工表 001 用户表,用户 ...

  5. Git Step by Step – (2) 本地Repo

    前面一篇文章简单介绍了Git,并前在Windows平台上搭建了Git环境,现在就正式的Git使用了. Git基本概念 在开始Git的使用之前,需要先介绍一些概念,通过这些概念对Git有些基本的认识,这 ...

  6. 通过SSH实现Windows与linux之间传输文件

    Linux是非常好的开发环境,但很多时候我们希望能够在Windows上操作,通过SSH协议可以实现两者之间传输文件. 一 需要在Linux系统上安装ssh-server,有的linux系统自带了. 查 ...

  7. Linux 添用户报错:useradd:警告:此主目录已经存在

    建立mysql用户.组 groupadd mysql useradd -g mysql mysql 然后删除 userdel mysql 再添用户和组加时,提示: 解决方法:删除用户不用userdel ...

  8. [Vim] Vim 常用基本操作

    1. 导航 1.1. 查看行号 :set number  显示行号 :set number!  隐藏行号 :.=  在底部显示当前行号 :=  在底部显示总行号 1.2. 移动光标 0 或 ^    ...

  9. RabbitMQ之总结

    P:生成者,消息产生者: C:消息消费者: 红:消息队列: java实现 步骤: 创建连接 从连接中创建通道(相当于JDBC中的Statement) 通过channel声明(创建)队列.(如果队列存在 ...

  10. 使用jquery的 $.grep实现es6的filter效果

    现在es6是趋势,习惯了es6会方便的多,但是有时候由于项目的限制,会限制es6的使用,在处理数组的时候,往往会想将一个数组进行过滤产生另一个新数组,如es6的filter 如下,我又一个数组,[1, ...