把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
/*
把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位

*/
char word[][]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
char str[];
scanf("%s",str);
int len=strlen(str);
int sum=;
for(int i=;i<len;i++){
sum+=str[i]-'';
}
//printf("sum:%d\n",sum);
sprintf(str,"%d",sum);
len=strlen(str);
int idx=str[]-'';
printf("%s",word[idx]);
for(int i=;i<len;i++){
idx=str[i]-'';
printf(" %s",word[idx]);
}
return ;
}

PAT甲题题解-1005. Spell It Right (20)-数位求和,水的更多相关文章

  1. PAT甲题题解-1001. A+B Format (20)-字符串处理,水

    计算A+B的和,并且按标准格式处理,每3个就要有个逗号 #include <iostream> #include <cstdio> #include <algorithm ...

  2. PAT甲题题解-1011. World Cup Betting (20)-误导人的水题。。。

    题目不严谨啊啊啊啊式子算出来结果是37.975样例输出的是37.98我以为是四舍五入的啊啊啊,所以最后输出的是sum+0.005结果告诉我全部错误啊结果直接保留两位小数就可以了啊啊啊啊 水题也不要这么 ...

  3. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

  4. PAT甲题题解-1124. Raffle for Weibo Followers-模拟,水题

    水题一个,贴个代码吧. #include <iostream> #include <cstdio> #include <algorithm> #include &l ...

  5. PAT甲题题解-1128. N Queens Puzzle (20)-做了一个假的n皇后问题

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789810.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  6. PAT甲题题解-1027. Colors in Mars (20)-水。。。

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  7. PAT甲题题解-1054. The Dominant Color (20)-排序/map

    原本用map,发现超时了,后来便先用数组存储排个序,最后for一遍统计每种颜色出现的次数(每种颜色的首位索引相减+1),找出最多的即可. #include <iostream> #incl ...

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

  9. PAT甲题题解-1023. Have Fun with Numbers (20)-大数加法

    和1024一样都是大数据的题,因为位数最多要20位,long long最多19位给一个num,求sum=num+num问sum包含的数字,是否是num的一个排列,即数字都一样,只是顺序不同罢了. #i ...

随机推荐

  1. October 10th 2017 Week 41st Tuesday

    If you focus on what you left behind you will never see what lies ahead. 如果你只顾回头看,那么你永远也看不见前方有什么. Ye ...

  2. NoSQL——not onlySQL不仅仅是SQL

    数据有很大一部分是由关系数据库管理系统(RDBMS)来处理. 1970年 E.F.Codd's提出的关系模型的论文 "A relational model of data for large ...

  3. PyQt5--EventSender

    # -*- coding:utf-8 -*- ''' Created on Sep 14, 2018 @author: SaShuangYiBing Comment: This example is ...

  4. sphinx编译安装

    install sphinx wget http://sphinxsearch.com/files/sphinx-2.0.8-release.tar.gz tar zxvf sphinx--relea ...

  5. Markdown基本语法规范

    1. 标题 #的个数即表示Hn, 一下依次从h1~h6.  也可在句尾添加同样个数的#(也可忽略) # This is H1 ## This is H2 ### This is H3 #### Thi ...

  6. redis命令手册

    Redis 键(key) 命令 命令 描述 Redis DEL 命令 该命令用于在 key 存在是删除 key. Redis Dump 命令 序列化给定 key ,并返回被序列化的值. Redis E ...

  7. OpenCV——反向投影(定位模板图像在输入图像中的位置)

    反向投影: #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namesp ...

  8. JAVA框架 SpringMVC RequestMapping讲解

    一.窄化请求映射 在class上做RequestMapping注解. 好处:避免在同一个项目中和其他人的url重复,出现请求混乱问题,便于管理. @Controller @RequestMapping ...

  9. eclipse中查看安装的所有插件,并选择性的将其卸载

    牢骚:前一段时间安装了一个将错误日志回传到邮箱的eclipse插件,安装此插件对捕获debug虽然很方便,但是也带了我不小的困扰,比如:eclipse加载速度慢.打开速度慢,有时还会引起一些异常,这不 ...

  10. Web.config中 mode="RemoteOnly" 跟mode="On" 区别

    转载网址:mode="RemoteOnly" 跟mode="On" 区别 <!-- 自定义错误信息 设置 customErrors mode=" ...