【PAT甲级】1005 Spell It Right (20 分)
题意:
给出一个非零整数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 分)的更多相关文章
- 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) 【字符串】
题目链接 https://www.patest.cn/contests/pat-a-practise/1005 思路 因为 n <= 10^100 所以 要用字符串读入 但是 100 * 100 ...
- Day 006:PAT练习--1005 Spell It Right (20 分)
上星期一直在写报告乱七八糟的,从今天开始不刷乙级的了,还是多刷甲级进步来得快一点! 显而易见,该题的关键在于将输入之和的每一位从高到低输出,这里我们发现题意中的输入数的范围为0-10^100,显然我们 ...
- 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 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- 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甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- 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 ...
- 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 ...
- PAT 甲级 1041 Be Unique (20 分)
1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...
随机推荐
- nodejs的req取参req.body,req.params,req.query
1/req.query: Get:/domo?name=ximiximi&blog=https://home.cnblogs.com/u/ximiximi-blog/ app.get('/do ...
- pysftp-tools
import pysftp import paramiko import os import unittest import json import warnings warnings.filterw ...
- GBK与Unicode的转换
一.GBK转换到Unicode编码 std::string Gbk2Unicode(std::string &strValue) { std::string strReturn; unsign ...
- Django - 美化显示request.META
def index(request): values = request.META.items() html = [] for k, v in values: html.append('<tr& ...
- Linux安装Redis服务
下载:wget http://download.redis.io/releases/redis-5.0.5.tar.gz 解压:tar -zxvf redis-5.0.5.tar.gz 进入redi ...
- cookie的封装
今天逛论坛,看到一个看起来写得好的函数,特此贴出分享: 原文地址[http://www.html-js.com/article/2638 ] 这个地址[https://github.com/jaywc ...
- Ubuntu18.04配置中文输入法(系统自带的)
Ubuntu18.04配置中文输入法 之前安装Ubuntu18.04的时候选择了english,现在要配置中文的输入法 打开系统设置 点击其中的工具按钮左边第一个 点击管理语言 ==如果系统刚安装可能 ...
- devexpress layoutview
1.设定数据源 2.设置view 3.设置 templat cardview 4 显示
- Cosmetic Bottles - Cosmetic Packaging: What Are The Characteristics Of Trends?
There are certain differences in products, of which cosmetics are the most obvious. In addition to t ...
- Python:时间日历基本处理
time 模块 提供了处理时间和表示之间转换的功能 获取当前时间戳 时间戳:从0时区的1970年1月1日0时0分0秒,到所给定日期时间的时间,浮点秒数,或者毫秒整数 获取方式: import time ...