题意:

给出一个非零整数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. angular iframe 加载失效解决办法已经自适应高度

    <iframe frameborder="0" id="iframe1"></iframe> $('#iframe1').attr('s ...

  2. idea选中文件时左侧菜单自动定位到文件所在位置

    一:设置成自动定位,如图: 二:点击项目工程目录上的阻击按钮,自动定位

  3. python基础之函数,递归,内置函数

    一.数学定义的函数与python中的函数 初中数学函数定义:一般的,在一个变化过程中,如果有两个变量x和y,并且对于x的每一个确定的值,y都有唯一确定的值与其对应,那么我们就把x称为自变量,把y称为因 ...

  4. 【代码学习】PYTHON装饰器

    一.装饰器 对原代码不修改的基础上完善代码 写代码要遵循开放封闭原则,虽然在这个原则是用的面向对象开发,但是也适用于函数式编程,简单来说,它规定已经实现的功能代码不允许被修改,但可以被扩展,即: 封闭 ...

  5. UIDocumentPickerViewController和UIDocumentInteractionController

    UIDocumentPickerViewController和UIDocumentInteractionController UIDocumentPickerViewController 补充一下,U ...

  6. java linux安装jdk,git, maven

    jdk8下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html mkdir ...

  7. Json日期格式化,出去返回的T

    第一种办法:前端JS转换: //格式化显示json日期格式 function showDate(jsonDate) { var date = new Date(jsonDate); var forma ...

  8. Java生鲜电商平台-小程序或者APP优惠券的设计与源码实战

    Java生鲜电商平台-小程序或者APP优惠券的设计与源码实战 说明:Java生鲜电商平台-小程序或者APP优惠券的设计与源码实战,优惠券是一种常见的促销方式,在规定的周期内购买对应商品类型和额度的商品 ...

  9. 喵星之旅-狂奔的兔子-svn安装及使用

    一.服务端安装配置 1.安装svn 创建版本库并配置 以root用户登录,或者具有sudo权限的用户,这里选择root. yum install subversion 都选择y 2.创建版本库并配置 ...

  10. 最全的Java操作Redis的工具类,使用StringRedisTemplate实现,封装了对Redis五种基本类型的各种操作!

    转载自:https://github.com/whvcse/RedisUtil 代码 ProtoStuffSerializerUtil.java import java.io.ByteArrayInp ...