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 ;
}


最新文章

  1. 【总结】总结写了3个React页面后遇到的各种坑
  2. java代码和spring框架读取xml和properties文件
  3. MySQL – optimizer_search_depth
  4. ACM之数学题
  5. 内核升级修复nfs
  6. CentOS 6.7安装Java JDK
  7. Win32汇编开始 Hello Asm
  8. javaTemplates-学习笔记三
  9. nodeJS之fs文件系统
  10. 指针运算中的运算符:&amp;和*
  11. 剑指Offer 34. 第一个只出现一次的字符 (字符串)
  12. win10系统安装两个版本的python,该怎么安装Django
  13. springboot的默认访问路径
  14. SharePoint Framework 企业向导(三)
  15. loadrunner12.5-添加检查点
  16. 【模板 &amp;&amp; 拓扑】 Dijkstra 单源最短路径算法
  17. leetCode题解之Self Dividing Numbers
  18. JPA 实体映射
  19. 继承AbstractRoutingDataSource再通过AOP实现动态数据源切换
  20. pandas中DataFrame使用

热门文章

  1. 【翻译】Knowledge-Aware Natural Language Understanding(摘要及目录)
  2. HTML页面隐藏值
  3. Java并发AtomicLongArray类
  4. centos 7.2 离线安装 gcc
  5. 【题解】小X的AK计划
  6. ubuntu中下载pycharm并添加到桌面
  7. Swift——(六)Swift中的值类型
  8. k8s进行与容器交互时报错:unable to upgrade connection: Unauthorized在k8s实现kubectl exec -it pod_ID sh出错解决
  9. 九、hibernate的查询(QBC)
  10. 【转】IntelliJ IDEA 2016.1.3注册破解激活