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 ...
随机推荐
- ansible with_subelements
with_subelements 循环列表中的子元素 (意想不到的地方会用到) --- - hosts: web tasks: - authorized_key: "user={{ item ...
- 【重大更新】DevExpress v17.2新版亮点—WPF篇(三)
DevExpress年终击穿底价,单套授权低至67折!仅剩最后10天!查看详情>>> 用户界面套包DevExpress v17.2终于正式发布,本站将以连载的形式为大家介绍各版本新增 ...
- Flappy Bird背后的故事
更多有价值的互联网文章:晓煦分享(http://www.ihuxu.com/share) 由越南游戏工程师阮哈东(Nguyen Ha Dong)开发的Flappy Bird这款游戏,画面不算精致且看起 ...
- PHP程序后台自动运行
如何让php程序自动执行,这个就需要用到一个函数了: int ignore_user_abort ( [bool setting] ) 定义和用法ignore_user_abort() 函数设置与客户 ...
- 掌握所有编程语言不是梦-转自csdn
还在讨论哪种编程语言最具价值?还在头疼怎么快速掌握新的语言?本文给出了一劳永逸的办法:掌握所有编程语言不是梦. 以下为译文: 我想在这里讨论的不是如何掌握一门编程语言,而是掌握所有的编程语言. 许多初 ...
- ModuleNotFoundError: No module named '_tkinter'
https://blog.csdn.net/blueheart20/article/details/78763208 apt search python3-tk apt install python3 ...
- Mitmproxy介绍及Python拦截代理
使用 mitmproxy + python 做拦截代理 转自:https://blog.wolfogre.com/posts/usage-of-mitmproxy/ 本文是一个较为完整的 mitm ...
- HDU 2813
http://acm.hdu.edu.cn/showproblem.php?pid=2813 裸二分图最优匹配,需要用两个map把武将名字映射到点的序号上 #include <iostream& ...
- PyCharm 注释
1.1 单行注释(行注释) 语法格式: #[空格]说明性文字信息 注:可放一行代码的后面进行说明 添加快捷键: Ctrl+/ 取消快捷键: 同上 1.2 多行注释(块注释) 语法格式: " ...
- eclipse启动maven项目
pom.xml 文件. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w ...