博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT---A1005. Spell It Right (20)
阅读量:4005 次
发布时间:2019-05-24

本文共 729 字,大约阅读时间需要 2 分钟。

题目要求:

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

解题思路:此题较为简单,只需要使用一个字符串存储输入,然后将每一位相加,按照要求输出即可。使用字符串是为了更方便的相加

参考代码:

#include 
using namespace std;int main(){ string s; //使用字符串获取输入,这样方便拆解 cin>>s; int sum = 0; for(int i=0;i
=0;j--) { cout <

转载地址:http://mbzfi.baihongyu.com/

你可能感兴趣的文章
计算机的发展史
查看>>
带WiringPi库的交叉编译如何处理一
查看>>
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Spring事务的七种传播行为
查看>>
ES写入找不到主节点问题排查
查看>>
Java8 HashMap集合解析
查看>>
ArrayList集合解析
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Android计算器实现源码分析
查看>>
Android系统构架
查看>>
Android 跨应用程序访问窗口知识点总结
查看>>
各种排序算法的分析及java实现
查看>>
SSH框架总结(框架分析+环境搭建+实例源码下载)
查看>>
js弹窗插件
查看>>
自定义 select 下拉框 多选插件
查看>>
js判断数组内是否有重复值
查看>>
js获取url链接携带的参数值
查看>>
gdb 调试core dump
查看>>
gdb debug tips
查看>>
arm linux 生成火焰图
查看>>