PAT 甲级 1005. Spell It Right (20)
来源:互联网 发布:nginx log 切割 编辑:程序博客网 时间:2024/06/14 19:07
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:12345Sample Output:
one five
#include <iostream>#include <vector>using namespace std;int main(){ string s[10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; string a; cin>>a; int sum=0; for(int i=0;i<a.length();i++){ sum+=(a[i]-'0'); } if(sum==0){ cout<<s[0]<<endl; return 0; } vector <int> v; while(sum!=0){ v.push_back(sum%10); sum/=10; } for(int i=v.size();i>0;i--){ cout<<s[v[i-1]]; if(i!=1) cout<<" "; } return 0;}
阅读全文
0 0
- PAT - 甲级 - 1005. Spell It Right (20)
- PAT甲级.1005. Spell It Right (20)
- 【PAT甲级】1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)
- PAT甲级 1005. Spell It Right (20)
- PAT甲级1005. Spell It Right (20)
- PAT 甲级 1005. Spell It Right (20)
- PAT甲级1005. Spell It Right
- PAT 甲级 1005. Spell It Right
- [PAT-甲级]1005.Spell It Right
- PAT甲级1005. Spell It Right
- PAT 甲级 1005. Spell It Right
- 1005. Spell It Right (20)-PAT甲级真题
- 【PAT甲级】【C++】1005. Spell It Right (20)
- PAT TEST 甲级1005. Spell It Right (20)
- PAT(甲级)1005. Spell It Right (20)
- PAT甲级练习1005. Spell It Right (20)
- PAT甲级 1005:Spell it Right
- 生产者/消费者模式
- 【noi】【2010】【能量收集】【莫比乌斯函数】
- Mac 配置MySQL
- Android EditText光标Cursor设置
- RTL8723BU BT&wifi
- PAT 甲级 1005. Spell It Right (20)
- 创新源于模仿之二:美化ListView的尝试
- Java代码调用HTTP请求工具类
- install for pytorch
- Questions about LogisticRegregation(2)
- 算法实验课(递归和分治法)
- oracle配置可查询的数据库
- 三方 app微信支付 java后端实现
- 设计模式六大原则(2):里氏替换原则