题目分析:用一个字符串输入之后遍历每一位求和后,不断%10获取最后一位存储下来,逆序用对应的英文单词输出(注意输入为0的情况)

 #include<iostream>
#include<string>
using namespace std; string a[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int b[]; int main(){
string s;
while(cin>>s){
int len = s.size();
int sum = ;
for(int i = ; i < len; i++){
int x = s[i] - '';
sum += x;
}
// cout<<sum<<endl;
int cnt = ;
if(sum == ){
b[cnt++] = ;
}else{
while(sum != ){
int x = sum % ;
sum /= ;
b[cnt++] = x;
}
}
for(int i = cnt-; i >= ; i--){
if(i != cnt-) printf(" ");
cout<<a[b[i]];
}
printf("\n");
}
return ;
}

PAT甲级1005水题飘过的更多相关文章

  1. PAT甲级1019水题飘过

    题目分析: 将n转成对应大小的b进制数之后判断是否为回文串,是则Yes,否则No #include<iostream> using namespace std; ]; //存放从0开始b进 ...

  2. PAT甲级1006水题飘过

    题目分析:由于不存在相同的两个时间(24:00:00和00:00:00不会同时存在),则我们假设两个全局变量存放到达的最早的时间和达到的最晚的时间,设置最早的初值为“23:59:59”,设置最晚的初值 ...

  3. PAT甲级1009水题飘过

    题目分析:简单的多项式的模拟乘法,你可以假设未知数为x,exp为x的指数,coe为x的系数,则很容易就把答案推算出来,注意答案是从指数的高往低输出,同时要注意的是这是多项式的乘法,虽然指数的范围只有0 ...

  4. PAT甲级1011水题飘过

    题目分析:对于输入的数据分三条,选出每条中最大值记录下来,按照题目要求算出最大可能的获利即可 #include<iostream> using namespace std; ]; //k数 ...

  5. PAT甲级1008水题飘过

    题目分析:上去下来到达的时间和数量 #include<iostream> using namespace std; ]; int main(){ int n; while(scanf(&q ...

  6. PAT甲级1002水题飘过

    #include<iostream> #include<string.h> using namespace std; ]; int main(){ int n1, n2; wh ...

  7. PAT甲级1001水题飘过

    #include<iostream> using namespace std; int main(){ int a, b; while(scanf("%d%d", &a ...

  8. PAT甲级训练刷题代码记录

    刷题链接:https://www.patest.cn/contests/pat-a-practise 1001 #include <iostream> #include <stdio ...

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

随机推荐

  1. 使用Win10自带的截图工具

    Win10自带的截图工具还是可以的,快捷键win+shift+s 截完图之后会有一个通知,你可以对截图进行二次编辑,编辑之后默认是立即保存的 再搭配着Fu图床工具使用,简直太爽了 讲一下怎么打开通知

  2. angular4.x实现一个全选,反选,外加从下一页返回上一页,选中上一次的操作记录

    productMap:any = new Map<string, string>(); //定义一个map的数据模型 //只要操作这个checkbox 那么只管把数据全部勾起了就行了 刷新 ...

  3. Centos7快速安装Rancher

    通过docker,我们可以快速安装rancher 安装步骤如下:[root@localhost ~]# #run运行,-d后台模式 --restart=always跟随docker启动,-p映射端口, ...

  4. 查看Oracle表空间以及用户与其默认表空间情况

    Oracle中一个表空间可能是多个用户的默认表空间,下面语句统计了用户及其默认表空间情况,如果用户多个,用户之间通过逗号分隔. select t.default_tablespace, to_char ...

  5. java jdbc使用SSH隧道连接mysql数据库demo

    java jdbc使用SSH隧道连接mysql数据库demo   本文链接:https://blog.csdn.net/earbao/article/details/50216999   packag ...

  6. MF 模拟器读取PC串口数据

    using System; using Microsoft.SPOT; using Microsoft.SPOT.Input; using Microsoft.SPOT.Presentation; u ...

  7. Vue脚手架菜鸟级错误 npm run dev

    ERROR Failed to compile with 1 errors Failed to resolve loader: stylus-loaderYou may need to install ...

  8. 浅谈PHP中pack、unpack的详细用法

    转自:https://segmentfault.com/a/1190000008305573 PHP中有两个函数pack和unpack,很多PHPer在实际项目中从来没有使用过,甚至也不知道这两个方法 ...

  9. mysql慢查询及查询优化

    mysql默认是没有开启慢查询的 1 查看慢查询的配置状态 show variables like 'slow_query%'; slow_query_log 慢查询开启状态 slow_query_l ...

  10. 修改Jupyter Notebook的默认打开路径

    一: (也可以直接将删除的部分修改成所要存储的文件路径,之后三个步骤就可以省去了) 二: 打开Windows的cmd,在cmd中输入jupyter notebook --generate-config ...