PAT-A 1005. Spell It Right (20)
来源:互联网 发布:微信h5制作软件 编辑:程序博客网 时间:2024/06/01 09:35
注意点:
此题是一个字符串的模拟题,注意结果为零的情况即可。
代码:
#include<iostream>#include<string>using namespace std;int main(){ string s; int length; int i, j, ans; int num[10]; cin >> s; string name[10] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; length = s.size(); ans = 0; for (i = 0; i < length; i++) { ans += s[i] - '0'; } if (ans == 0) { cout << name[0] << endl; return 0; } num[0] = 0; while (ans > 0) { num[0]++; num[num[0]] = ans % 10; ans /= 10; } cout << name[num[num[0]]]; for (i = num[0] - 1; i > 0; i--) cout << " " << name[num[i]]; cout << endl; return 0;}
阅读全文
0 0
- PAT A 1005. Spell It Right (20)
- PAT(A) - 1005. Spell It Right (20)
- pat-a 1005. Spell It Right (20)
- PAT A 1005. Spell It Right (20)
- PAT-A 1005. Spell It Right (20)
- PAT-A-1005. Spell It Right (20)
- PAT-A 1005. Spell It Right (20)
- PAT A 1005. Spell It Right
- PAT-A 1005. Spell It Right
- (PAT)1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- PAT: 1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- [PAT]1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- pat 1005. Spell It Right (20)
- [PAT]1005. Spell It Right (20)
- PAT 1005. Spell It Right (20)
- 新建一个基于Maven的SpringMVC的Web工程遇到的问题
- 深入理解Java虚拟机之一运行时数据区域
- JavaScript实现简单的图片轮播(通过点击左右焦点切换)
- 逻辑运算与循环结构
- Oracle 高级子查询
- PAT-A 1005. Spell It Right (20)
- UvaLive 4255 Guess(拓扑排序)
- 【干货】Linux服务器高并发调优实战
- Spring AOP 实现原理
- 【代码笔记】iOS-手机版本号,机型,操作系统版本,设备唯一标识符
- 2017.8.22
- 数据库切分(4)之全局主键生成策略
- Unity时间管理类,用来做一些方法的延迟调用
- 正则表达式