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 ...
随机推荐
- L1-024 后天
如果今天是星期三,后天就是星期五:如果今天是星期六,后天就是星期一.我们用数字1到7对应星期一到星期日.给定某一天,请你输出那天的“后天”是星期几. 输入格式: 输入第一行给出一个正整数D(1 ≤ D ...
- iOS多线程编程:线程同步总结
1:原子操作 - OSAtomic系列函数 iOS平台下的原子操作函数都以OSAtomic开头,使用时需要包含头文件<libkern/OSBase.h>.不同线程如果通过原子操作函数对同一 ...
- Emacs矩形操作
原始矩形块模式 emacs以C-x r开头的命令来进行矩形操作.先用C-space或者C-@设一个mark,移动光标到另一点,用以下命令进行列操作: C-x r r 复制一个矩形区域到寄存器 C-x ...
- Express文件上传之Multer
Express文件上传之Multer Multer是一个nodejs中间件,用来处理http提交multipart/form-data,也就是文件上传.它是在busboy的基础上开发的. 在我看来,M ...
- exit和return
函数名: exit() 所在头文件:stdlib.h(如果是”VC6.0“的话头文件为:windows.h) 功 能: 关闭所有文件,终止正在执行的进程. exit(1)表示异常退出.这个1是返回给操 ...
- c++ 字符数组-print and 写入文件
1.print ][] = { }; method1: 为了打印出unsigned char数据所对应的数值,可以将其强制转换成int类型,并做打印输出. std::cout << ][] ...
- Hihocoder1883 : 生成树问题(并查集+树剖+线段树)
描述 有一个无向图,有n个点,m1条第一类边和m2条第二类边.第一类边有边权,第二类边无边权.请为第二类的每条边定义一个边权,使得第二类边可能全部出现在该无向图的最小生成树上,同时要求第二类边的边权总 ...
- C#/.NET 使用 CommandLineParser 来标准化地解析命令行
CommandLineParser 是一款用于解析命令行参数的 NuGet 包.你只需要关注你的业务,而命令行解析只需要极少量的配置代码. 本文将介绍如何使用 CommandLineParser 高效 ...
- Struts2重学习之作用域的获取
第一种:获取requestMap,sessionMap,applicationMap, HttpServletRequest,HttpServletResponse对象的获取,在Struts2中 pu ...
- from表单的分向提交
一:需求: 思路:document.form.action,表单分向提交,javascript提交表单同一个表单可以根据用户的选择,提交给不同的后台处理程序.即,表单的分向提交.如,在编写论坛程序时, ...