1082 Read Number in Chinese (25 分)
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu
first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu
. Note: zero (ling
) must be handled correctly according to the Chinese tradition. For example, 100800 is yi Shi Wan ling ba Bai
.
Input Specification:
Each input file contains one test case, which gives an integer with no more than 9 digits.
Output Specification:
For each test case, print in a line the Chinese way of reading the number. The characters are separated by a space and there must be no extra space at the end of the line.
Sample Input 1:
-123456789
Sample Output 1:
Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu
Sample Input 2:
100800
Sample Output 2:
yi Shi Wan ling ba Bai
分析: 这个题有点复杂。。慢慢模拟。。debug了好久,要注意一个数中间空了多个零,只要输出一个零。。。
一开始没注意,女朋友随便给我出了个数。。竟然真错在这里了,她是不是有干测试的潜质= =
/** * Copyright(c) * All rights reserved. * Author : Mered1th * Date : 2019-02-24-22.11.37 * Description : A1082 */ #include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<unordered_set> #include<map> #include<vector> #include<set> using namespace std; ]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; ]={"Yi","Wan"}; void func(int n){ string s=to_string(n); ){ cout<<num[s[]-']; } ){ cout<<num[s[]-']<<" "<<"Shi"; ]!='){ cout<<]-']; } } ){ cout<<num[s[]-']<<" "<<"Bai"; ]=='){ ]!='){ cout<<]-']; } } else{ cout<<]-']<<" Shi"; ]!='){ cout<<]-']; } } } ){ cout<<num[s[]-']<<" Qian"; ]=='){ ]=='){ ]!='){ cout<<]-']; } } else{ cout<<]-']<<" Shi"; ]!='){ cout<<]-']; } } } else{ cout<<]-']<<" Bai"; ]=='){ ]!='){ cout<<]-']; } } else{ cout<<]-']<<" Shi"; ]!='){ cout<<]-']; } } } } } int main(){ #ifdef ONLINE_JUDGE #else freopen("1.txt", "r", stdin); #endif int s; cin>>s; ){ printf("ling"); ; } ){ printf("Fu "); s=-s; } ; /; ; bool flag=false; if(s1){ func(s1); cout<<]<<" "; } if(s2){ string t2=to_string(s2); ){ ;i<=t2.size();i++){ '){ cout<<"ling "; } } } func(s2); cout<<]<<" "; } if(s3){ && s2==){ cout<<"ling "; flag=true; } string t3=to_string(s3); ){ ;i<=t3.size();i++){ ' && flag==false){ cout<<"ling "; flag=true; } } } func(s3); } ; }
1082 Read Number in Chinese (25 分)的更多相关文章
- 1082 Read Number in Chinese (25分)
// 1082.cpp : 定义控制台应用程序的入口点. // #include <iostream> #include <string> #include <vecto ...
- 【PAT甲级】1082 Read Number in Chinese (25 分)
题意: 输入一个九位整数,输出它的汉字读法(用拼音表示). trick: 字符串数组""其实会输出一个空格,而不是什么都不输出,导致测试点0和4格式错误. AAAAAccepted ...
- A1082 Read Number in Chinese (25 分)
1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed t ...
- 1082. Read Number in Chinese (25)
题目如下: Given an integer with no more than 9 digits, you are supposed to read it in the traditional Ch ...
- 1082. Read Number in Chinese (25)-字符串处理
题意就是给出9位以内的数字,按照汉子的读法读出来. 读法请看下方的几个例子: 5 0505 0505 伍亿零伍佰零伍万零伍佰零伍 5 5050 5050 伍亿伍仟零伍拾万伍仟零伍拾 (原本我以为这个 ...
- PAT (Advanced Level) 1082. Read Number in Chinese (25)
模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- pat1082. Read Number in Chinese (25)
1082. Read Number in Chinese (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yu ...
- A1082 Read Number in Chinese (25)(25 分)
A1082 Read Number in Chinese (25)(25 分) Given an integer with no more than 9 digits, you are suppose ...
- PAT 1082 Read Number in Chinese[难]
1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to ...
随机推荐
- apsx 页面 if(!ispostback)其用法和作用 什么时候该用?
一个页面第一次显示的时候 isPostBack=false 然后你在这个页面上点击按钮或其它东西提交的时候, isPostBack=true 一般这个函数里面的内容是指第一次打开这个页面的时候要做的事 ...
- pdo::quey excu excute 区别
PDO::query(PHP环境下同)和PDOStatement::execute函数均能实现SELECT查询功能,但官方文档并未见对此设计初衷的说明,此外还有个PDO::exec函数功能也很类似.天 ...
- 子域名爆破&C段查询&调用Bing查询同IP网站
在线子域名爆破 <?php function domainfuzz($domain) { $ip = gethostbyname($domain); preg_match("/\d+\ ...
- Android 自定义圆形旋转进度条,仿微博头像加载效果
微博 App 的用户头像有一个圆形旋转进度条的加载效果,看上去效果非常不错,如图所示: 据说 Instagram 也采用了这种效果.最近抽空研究了一下,最后实现的效果是这样: 基本上能模拟出个大概,代 ...
- win10下tomcat环境搭建
一.下载tomcat 用浏览器打开tomcat官网:http://tomcat.apache.org/ 在左侧的导航栏Download下方选择最新的Tomcat 9,点击页面下方的“ 64-bit W ...
- 会声会影X7安装不了,总是提示已经安装其他版本,怎么办
会声会影X7安装不了,总是提示已经安装其他版本,怎么办 卸载c++2008,安装会声会影,ok. 卸载工具:Windows Install Clean Up
- ReSharper2017.3的列对齐、排版格式、列对齐错误的修复
ReSharper代码排版格式 列对齐 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- ...
- Java8函数式编程学习笔记(初探)
编程语言的整个目的就在于操作值,要是按照历史上编程语言的传统,这些值被成为一等值,而编程语言中的其他结构也许有助于表示值的结构,但在程序执行期间不能传递,因此为二等值,比如方法和类等则是二等值,类可以 ...
- 【codeforces】Bear and Three Balls(排序,去重)
Bear and Three Balls Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I6 ...
- HDU 4666 最远曼哈顿距离
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4666 关于最远曼哈顿距离的介绍: http://blog.csdn.net/taozifish/ar ...