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 Fufirst 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 ...
随机推荐
- 1017 A除以B
本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数.你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立. 输入格式: 输入在一行中依次给出 A 和 B,中间以 ...
- 用MyEclipse JPA创建项目(三)
MyEclipse 3.15 Style——在线购买低至75折!火爆开抢>> [MyEclipse最新版下载] 本教程介绍了MyEclipse中的一些基于PA的功能. 阅读本教程时,了解J ...
- 添加MyEclipse WebSphere Portal Server支持(二)
MyEclipse个人授权 折扣低至冰点!立即开抢>> [MyEclipse最新版下载] 三.支持WebSphere Portal部署 当您为WebSphere Portal 7.0或8. ...
- mysql数据库索引相关
一 介绍 什么是索引? 索引在MySQL中也叫做“键”,是存储引擎用于快速找到记录的一种数据结构.索引对于良好的性能非常关键,尤其是当表中的数据量越来越大时,索引对于性能的影响愈发重要.索引优化应该是 ...
- <constant name="struts.devMode" value="false" />
在开发中,我们常常会遇到<constant name="struts.devMode" value="false" />,这是struts2的特性, ...
- Python学习(003)-列表[]
列表[] a=['张帅','李四','王五','陈六','黄旗'] print(a[2]) 王五 print(a[1:3]) ['李四','王五'] 左包含,右不包含 print(a[1: ...
- UI基础:UI程序执行顺序(UIApplicationMain()函数),自定义视图 分类: iOS学习-UI 2015-07-02 22:09 68人阅读 评论(0) 收藏
UI程序的一般执行顺序: 先进入main里面,执行函数UIApplicationMain(),通过该函数创建应用程序对象和指定其代理并实现监听,当执行函数UIApplicationMain()时还会做 ...
- centos 7 NAT模式网络设置
打开虚拟机.菜单栏点击‘编辑’ -> ‘虚拟网络设置’. 注意下图红色框地方的设置: 然后进入linux系统,编辑网络配置: vi /etc/sysconfig/network-scripts/ ...
- HDU 4864
http://acm.hdu.edu.cn/showproblem.php?pid=4864 #include <iostream> #include <cstdio> #in ...
- C语言与VT100控制码编程
C语言与VT100控制码编程 声明: . 如果您打算阅读本文,希望您已经了解过C语言的基本语法,本文不对C语言的基本语法进行说明,因为那些东西几乎唾手可得; . 本文在vim中编辑,请尽量是用vim进 ...