PTA 1005 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 (≤).
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 <iostream>
#include <cstring>
#include <string>
using namespace std; const string x[]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int main(){
char ch[];
int a[],l,sum=;
cin.getline(ch,);
for (int i=;i<=;i++){
if (isdigit(ch[i])){
sum+=ch[i]-'';
}
else{
break;
}
}
for (int i=;;i++){
a[i]=sum % ;
sum/=;
if (sum==){
l=i+;
break;
}
}
for (int i=l-;i>;i--){
cout << x[a[i]] << " ";
}
cout << x[a[]];
return ;
}
PTA 1005 Spell It Right的更多相关文章
- PTA 1005 Spell It Right (20)(20 分)水题
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...
- 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 ...
- PAT 1005 Spell It Right
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all ...
- PAT 甲级 1005 Spell It Right (20)(代码)
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...
- PAT甲1005 Spell it right【字符串】
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...
- 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 ...
- PAT 甲 1005. Spell It Right (20) 2016-09-09 22:53 42人阅读 评论(0) 收藏
1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given ...
- 1005 Spell It Right
1005 Spell It Right Given a non-negative integer N, your task is to compute the sum of all the dig ...
- 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 the ...
随机推荐
- linux下的 $ ./configure $ sudo make && sudo make install
$ ./configure $ sudo make && sudo make install 1)./configure命令就是执行当前目录的名为configure的脚本,主要的作用是 ...
- 关于C语言数组的小练习--笔记
#include <stdio.h> #include <windows.h> #include <mmsystem.h> #include <string. ...
- python学习记录(四)
0828--https://www.cnblogs.com/fnng/archive/2013/04/18/3029807.html 0828--https://www.cnblogs.com/fnn ...
- 最小生成树(二)prim
今天为大家带来最小生成树的第二种实现方式,比起kruskal来说,prim相对要复杂一些,在稠密图的表现中表现较好,最优情况下也是nlogn级别. 描述: 1).输入:一个加权连通图,其中顶点集合为V ...
- 【Java并发工具类】Semaphore
前言 1965年,荷兰计算机科学家Dijkstra提出的信号量机制成为一种高效的进程同步机制.这之后的15年,信号量一直都是并发编程领域的终结者.1980年,管程被提出,成为继信号量之后的在并发编程领 ...
- LAMP: 分布式 HTTP 2.4.25 + PHP 5.4.13 + MySQL 5.5.28 分离部署
目录 A. 环境说明:B. 效果截图:C. HTTP编译安装D. MySQL二进制安装E. PHP源码编译安装F. PHP连接HTTPG. PHP支持扩展功能xcacheH. PHP连接MySQLI. ...
- 小程序websocket心跳库——websocket-heartbeat-miniprogram
前言 在16年的时候因为项目接触到websocket,而后对心跳重连做了一次总结,写了篇博客,而后18年对之前github上的demo代码进行了再次开发和开源,最终封装成库.如下: 博客:https: ...
- geo常见需求
常见的地理位置相关需求有: 1.查找附近的人 2.显示两点距离 3.点是否在指定范围内(地理围栏) redis.MongoDB.mysql都已支持geo 几种geo方案对比 https://blog. ...
- 2.【Spring Cloud Alibaba】实现负载均衡-Ribbon
负载均衡的两种方式 如何实现负载均衡 目前已经实现让A总能找到B,如何实现负载均衡 负载均衡的两种方式 服务器端负载均衡 客户端负载均衡 使用Ribbo实现负载均衡 Ribbon是什么 ==Netfl ...
- Hexo | 超详细的hexo+githhub page搭建过程
首先安装node.js 安装git 去Git官网根据你的电脑参数,下载对应版本. 下载完成,通过在命令行输入 git version 查看是否安装成功,有输出版本号说明安装成功. 鼠标邮件菜单里就多了 ...