题意:

给出一个非零整数N(<=10^100),计算每位之和并用英文输出。

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
string s;
char num[][]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main(){
cin>>s;
int ans=;
for(int i=;i<s.length();++i)
ans+=s[i]-'';
int x=ans/;
ans%=;
int y=ans/;
ans%=;
int z=ans;
if(x)
cout<<num[x]<<" "<<num[y]<<" "<<num[z];
else if(y)
cout<<num[y]<<" "<<num[z];
else
cout<<num[z];
return ;
}

【PAT甲级】1005 Spell It Right (20 分)的更多相关文章

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

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

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

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

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

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

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

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

  7. PAT甲级:1152 Google Recruitment (20分)

    PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...

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

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

  10. PAT 甲级 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

随机推荐

  1. Hadoop架构: 流水线(PipeLine)

    该系列总览: Hadoop3.1.1架构体系——设计原理阐述与Client源码图文详解 : 总览 流水线(PipeLine),简单地理解就是客户端向DataNode传输数据(Packet)和接收Dat ...

  2. 【转载】 BIOS设置选项详细解释——CPU核心篇

    原文地址: http://kuaibao.qq.com/s/20180226A1G1OC00?refer=spider ---------------------------------------- ...

  3. codeforces-Three Friends

      Three Friends Three friends are going to meet each other. Initially, the first friend stays at the ...

  4. 【C语言】将输入的10个数排序

    代码: #include <stdio.h> int main() { ], t; int i, j, max; printf("请输入10个数:\n"); ; i & ...

  5. 数据库单,多,全库、冷热备份思路及备份与还原(mysqldump)

    热备份:服务开启状态下进行备份, 冷备份:服务关闭状态进行备份, 冷备份 数据库原有内容如下: MariaDB [(none)]> show databases;+--------------- ...

  6. DreamWeaver CC 中的回车

    在Dreamweaver CC中换行有两种: 第一种是在设计视图中直接回车,对应的代码是<p>标签,即新生成一个段落. (注:在DreamWeaver CC编辑的代码中,按下回车相当于 ) ...

  7. mongodb 用户指引

    维护人:陈权 一.mongodb install on linuxcurl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6 ...

  8. 微服务架构中的Redis

    了解如何将Redis与Spring Cloud和Spring Data一起使用以提供配置服务器,消息代理和数据库. Redis可以广泛用于微服务架构中.它可能是少数流行的软件解决方案之一,你的应用程序 ...

  9. ProtoBuf试用与JSON的比较

    介绍 ProtoBuf 是google团队开发的用于高效存储和读取结构化数据的工具.什么是结构化数据呢,正如字面上表达的,就是带有一定结构的数据.比如电话簿上有很多记录数据,每条记录包含姓名.ID.邮 ...

  10. QLabel设置伙伴关系和快捷键(Alt+首字母)

    Qlabe中设置伙伴关系是使用Setbuddy函数: Qlabel.Setbuddy(QLineEdit) #将Qlabel和QLineEdit之间设置伙伴关系 另外,需要配合热键(快捷键)进行使用, ...