A1082 Read Number in Chinese (25 分)
2024-09-03 09:01:36
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
#include<bits/stdc++.h>
using namespace std; string Week[]={
"MON","TUE","WED","THU","FRI","SAT","SUN"
}; string num[]={
"ling","yi","er","san","si","wu","liu","qi","ba","jiu"
}; string wei[]={
"Shi","Bai","Qian","Wan","Yi"
}; int main(){ string str; cin>>str; int len=str.size(); int left=,right=len-; if(str[]=='-')
{
left++;
cout<<"Fu";
} while(left+<=right) //注意等于号
right-=; while(left<len){ bool flag=false;
bool isPrint=false; while(left<=right){ if(left>&&str[left]==''){
flag=true;
}else{
if(flag){
cout<<" ling";
flag=false;
}
isPrint=true; if(left>)cout<<" "; //注意格式空格
cout<<num[str[left]-'']; if(left!=right)
cout<<" "<<wei[right-left-]; } left++;
} if(isPrint==true&&right!=len-){
cout<<" "<<wei[(len--right)/+];
} right+=; } return ;
}
最新文章
- 【总结】总结写了3个React页面后遇到的各种坑
- java代码和spring框架读取xml和properties文件
- MySQL – optimizer_search_depth
- ACM之数学题
- 内核升级修复nfs
- CentOS 6.7安装Java JDK
- Win32汇编开始 Hello Asm
- javaTemplates-学习笔记三
- nodeJS之fs文件系统
- 指针运算中的运算符:&;和*
- 剑指Offer 34. 第一个只出现一次的字符 (字符串)
- win10系统安装两个版本的python,该怎么安装Django
- springboot的默认访问路径
- SharePoint Framework 企业向导(三)
- loadrunner12.5-添加检查点
- 【模板 &;&; 拓扑】 Dijkstra 单源最短路径算法
- leetCode题解之Self Dividing Numbers
- JPA 实体映射
- 继承AbstractRoutingDataSource再通过AOP实现动态数据源切换
- pandas中DataFrame使用
热门文章
- 【翻译】Knowledge-Aware Natural Language Understanding(摘要及目录)
- HTML页面隐藏值
- Java并发AtomicLongArray类
- centos 7.2 离线安装 gcc
- 【题解】小X的AK计划
- ubuntu中下载pycharm并添加到桌面
- Swift——(六)Swift中的值类型
- k8s进行与容器交互时报错:unable to upgrade connection: Unauthorized在k8s实现kubectl exec -it pod_ID sh出错解决
- 九、hibernate的查询(QBC)
- 【转】IntelliJ IDEA 2016.1.3注册破解激活