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 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 (≤10100).
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
题意:
计算数字N的每一位合,然后用英语读每一位。
题解:
#include <iostream>
using namespace std;
int main() {
long long sum = 0;
string n;
cin >> n;
for(int i=0;i<n.size();i++) sum+=(n[i]-'0');
string ans = to_string(sum);
string tamp[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
for(int i=0;i<ans.size();i++) {
if(i) cout << " ";
cout << tamp[ans[i]-'0'];
}
return 0;
}
1005 Spell It Right (20分)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 【题解】P2024 [NOI2001]食物链 - 数据结构 - 并查集
P2024 [NOI2001]食物链 声明:本博客所有题解都参照了网络资料或其他博客,仅为博主想加深理解而写,如有疑问欢迎与博主讨论✧。٩(ˊᗜˋ)و✧*。 题目描述 动物王国中有三类动物 \(A,B ...
- mac 使用记录
iterm 配合 lrzsz 实现 上传下载
- vscode 使用记录
快捷键 Cmd+P 查找最近的文件 Ctrl+cmd + P 打开命令面板 Ctrl+tab文件间切换 Ctrl+` 打开终端 Cmd +b 隐藏侧边栏 VScode对多行编辑有两种模式 第一种模式 ...
- 博云DevOps 3.0重大升级 | 可用性大幅提升、自研需求管理&自定义工作流上线,满足客户多样化需求
DevOps能够为企业带来更高的部署频率.更短的交付周期与更快的客户响应速度.标准化.规范化的管理流程,可视化和数字化的研发进度管理和可追溯的版本也为企业带来的了更多的价值.引入DevOps成为企业实 ...
- TensorFlow keras读取图片
from tensorflow.python.keras.preprocessing.image import load_img,img_to_array def main(): #tagert_si ...
- sudo: 在加载插件“sudoers_policy”时在 /etc/sudo.conf 第 0 行出错 sudo: /usr/lib/sudo/sudoers.so 必须只对其所有者可写 sudo: 致命错误,无法加载插件
解决办法: su root chmod 644 /usr/lib/sudo/sudoers.so chown -R root /usr/lib/sudo 千万不要给 /usr 赋全部权限!!! ...
- 如何给 Visual Studio 的输出程序添加版本信息
出处:https://stackoverflow.com/questions/284258/how-do-i-set-the-version-information-for-an-existing-e ...
- Qt提示:setLayout: Attempting to set QLayout "" on MainWindow "MainWindow", which already has a layout
如题,出现这个的原因是,如果你的窗口继承的是QMainwindow,需要设置setCentralWidget(); 如下: QWidget * widget = new QWidget ( mainW ...
- mysql-管理命令【创建用户、授权、修改密码、删除用户和授权、忘记root密码】
一.创建用户 命令: CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 关键参数说明: username - 创建登录用户名, host ...
- CF思维联系–CodeForces -224C - Bracket Sequence
ACM思维题训练集合 A bracket sequence is a string, containing only characters "(", ")", ...