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 ...
随机推荐
- gerrit代码简单备份方案分享
由于前期部署了gerrit代码审核系统,开发调整后的线上代码都放到gerrit上,这就要求我们要保证代码的安全.所以,对gerrit代码的备份至关重要! 备份的策略是:1)先首次将gerrit项目代码 ...
- tableView优化思路
一般优化的思路: 提前计算并缓存好高度(布局),因为heightForRowAtIndexPath:是调用最频繁的方法. 复杂界面可采用异步绘制. 在大量图片展示时,可以滑动时按需加载. 尽量少用或不 ...
- BugPhobia开发篇章:Beta阶段第VIII次Scrum Meeting
0x01 :Scrum Meeting基本摘要 Beta阶段第八次Scrum Meeting 敏捷开发起始时间 2015/12/22 00:00 A.M. 敏捷开发终止时间 2015/12/22 23 ...
- 《Linux内核分析》第五周笔记 扒开系统调用的三层皮(下)
扒开系统调用的三层皮(下) 一.给menuOS增加time和time-asm 通过内核调试系统调用.将上次做的实验加入到menusOS,变成menusOS里面的两个命令. 1 int Getpid(i ...
- PAT L2-027 名人堂与代金券
https://pintia.cn/problem-sets/994805046380707840/problems/994805055176163328 对于在中国大学MOOC(http://www ...
- Node json
//1:加载相关模块 http express mysqlconst http = require("http");const mysql = require("mysq ...
- Java微信二次开发(四)
自定义文字菜单,暂时先实现一个根据用户输入城市名称来查询邮政编码和查询区号的功能 需要导入库:mysql-connector-java-5.0.8-bin.jar 第一步:利用Navicat新建一个用 ...
- Java 数组实现 stack
首先定义 IStack package cn.com.example.stack; /** * Created by Jack on 2017/3/8. */ public interface ISt ...
- html css類和css()
addClass():一個或者多個元素添加一個或者多個類 $("元素一,元素2,元素3").addClass(“類名1 類名2”) removeClass():一個或者多個元素刪 ...
- JavaScript——AJAX
AJAX技术是网页构建的必备技能之一,本文希望能帮助大家轻松的学习这项技术 一.什么是ajax? ajax(异步javascript xml) 能够刷新局部网页数据而不是重新加载整个网页. 二.如何使 ...