A1005. Spell It Right
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<cstdio>
#include<iostream>
using namespace std;
char data[][] = {"zero", "one", "two", "three","four", "five", "six", "seven", "eight", "nine"};
int main(){
char num[];
int sum = , list[];
scanf("%s", num);
for(int i = ; num[i] != '\0'; i++)
sum += (num[i] - '');
int a, i = ;
do{
a = sum % ;
sum = sum / ;
list[i++] = a;
}while(sum != );
i--;
printf("%s", data[list[i--]]);
while(i >= ){
printf(" %s", data[list[i]]);
i--;
}
cin >> a;
return ;
}
A1005. Spell It Right的更多相关文章
- PAT A1005 Spell It Right (20)
书中AC代码 #include <cstdio> #include <cstring> #include <iostream> char num[10][10] = ...
- PAT甲级——A1005 Spell It Right
题目描述 Given a non-negative integer N, your task is to compute the sum of all the digits of N, and out ...
- PTA A1005&A1006
第三天 A1005 Spell It Right (20 分) 题目内容 Given a non-negative integer N, your task is to compute the sum ...
- PAT/字符串处理习题集(二)
B1024. 科学计数法 (20) Description: 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+ ...
- PAT题目AC汇总(待补全)
题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- 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 ...
- Spell checker
Spell checker Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- [solr] - spell check
solr提供了一个spell check,又叫suggestions,可以用于查询输入的自动完成功能auto-complete. 参考文献: https://cwiki.apache.org/conf ...
随机推荐
- default construction
4种情况下编译器会构造出nontrivial(有用)的构造函数 带有default construction的member class object 我们有两个class: class Foo { p ...
- python-scapy学习笔记-(1)
主要功能函数sniff sniff(filter="",iface="any",prn=function,count=N) filter参数允许我们对Scapy ...
- php7与之前的区别和更新【转】
http://blog.csdn.net/u011957758/article/details/73320083 本文是一篇讲座听后+后续研究的总结. 话说当年追时髦,php7一出就给电脑立马装上了, ...
- Practice5.1 测试与封装5.1
结对同伴: 姓名 学号 博客地址 叶子鹏 201306114420 http://www.cnblogs.com/kazehanaai/ 王佳宁 201306114434 http://www.cnb ...
- <四则运算>第二次冲刺
这一次冲刺的主要内容是完善我们的界面,是我们的APP界面更规划更标准一点, 然后还要添加一些新算法. 距离客户的需求已经一半了. 代码正在完善中,稍后上传...
- A Survey of Machine Learning Techniques Applied to Software Defined Networking (SDN): Research Issues and Challenges
将机器学习用到SDN中的综述:研究的问题和挑战 从流量分类.路由优化.服务质量(Qos)/体验质量(QoE)预测.资源管理和安全性的角度,回顾了机器学习算法如何应用于SDN领域. 相关知识 在SDN中 ...
- [2017BUAA软工]第0次博客作业
第一部分:结缘计算机 1.你为什么选择计算机专业?你认为你的条件如何?和这些博主比呢? 当初选择计算机专业作为自己报考大学的第一志愿,主要是看重了市场对于计算机行业人士的巨大需求,同时也感慨于计算机行 ...
- CAS的应用场景
国外应用(需FQ尝试): 来自CAS官网推荐的Demo http://casserver.herokuapp.com/cas/login https://casserver.herokuapp.com ...
- Tomcat7解决java.lang.OutOfMemoryError: PermGen space
上述两参数,可根据实际情况,逐渐调大.
- STL数据结构
priority_queue "C++ reference"上如此解释priority queue:"This context is similar to a heap, ...