1002.写出这个数
来源:互联网 发布:淘宝有哪些奇葩商品 编辑:程序博客网 时间:2024/05/16 14:59
#include "stdafx.h"string num_table[] = { "ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu" }; //将每个数字对应的拼音保存在数组里string wrt(int n){ string str = num_table[n]; return str;}int _tmain(int argc, _TCHAR* argv[]){ char num_1; //因为输入的数可能很大,所以用char型来保存每一位防止溢出 int i = 0; int cnt = 0; while ((num_1 = getchar()) != '\n') //一直输入,直到遇到回车 { cnt += (num_1 - '0'); //char型减去‘0’直接就是数字 } int temp = 0; deque<string> str; //使用deque型容器,方便每次将新数插入开头 while (cnt) { temp = cnt % 10; str.push_front(wrt(temp)); cnt /= 10; } for (auto i = str.cbegin(); i != str.cend(); ++i) { if (i == str.cend() - 1) { cout << *i; } else cout << *i << ' '; } return 0;}
0 0
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002.写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002.写出这个数
- 1002.写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- 1002. 写出这个数
- Oracle12c学习(二)---Linux下SQL Developer 安装
- OpenJudge_P2988 计算字符串距离(DP)
- A星算法
- 二叉树的层序遍历
- 单词接龙
- 1002.写出这个数
- 杭电ACM1134——Game of Connections
- iOS:openURL
- 学习笔记 --- 线段树
- Android 图片压缩
- Sublime Text3 编译多个文件
- 网站提权
- 使用Visio画用例图没有include(包含)关系的解决办法
- ssh机器间添加信任关系