模拟题。

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<cmath>
  4. #include<vector>
  5. #include<map>
  6. #include<stack>
  7. #include<queue>
  8. #include<string>
  9. #include<iostream>
  10. #include<algorithm>
  11. using namespace std;
  12.  
  13. string num[]=
  14. {
  15. "ling","yi","er","san","si",
  16. "wu","liu","qi","ba","jiu"
  17. };
  18. string tmp="";
  19. string ans="";
  20. string s="";
  21.  
  22. string f(string TMP)
  23. {
  24. if(TMP[]==''&&TMP[]==''&&TMP[]==''&&TMP[]=='') return "ling";
  25. string t="";
  26. int p;
  27. for(int i=TMP.length()-;i>=;i--)
  28. if(TMP[i]!='') {p=i; break;}
  29.  
  30. for(int i=;i<=p;i++) t=t+TMP[i];
  31.  
  32. if(t=="" ) return "ling";
  33.  
  34. if(t.length()==) return "ling";
  35. if(t.length()==) return num[t[]-''];
  36. if(t.length()==)
  37. {
  38. if(t[]=='') return num[t[]-'']+" Shi";
  39. return num[t[]-'']+" shi "+num[t[]-''];
  40. }
  41. if(t.length()==)
  42. {
  43. if(t[]==''&&t[]=='') return num[t[]-'']+" Bai";
  44. if(t[]==''&&t[]!='') return num[t[]-'']+" Bai "+num[t[]-'']+" Shi";
  45. if(t[]!=''&&t[]=='') return num[t[]-'']+" Bai ling "+num[t[]-''];
  46. if(t[]!=''&&t[]!='') return num[t[]-'']+" Bai "+num[t[]-'']+" Shi "+num[t[]-''];
  47. }
  48. if(t.length()==)
  49. {
  50. if(t[]==''&&t[]==''&&t[]=='') return num[t[]-'']+" Qian";
  51. if(t[]!=''&&t[]==''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-''];
  52. if(t[]==''&&t[]!=''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-'']+" Shi";
  53. if(t[]!=''&&t[]!=''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-'']+" Shi "+num[t[]-''];
  54. if(t[]==''&&t[]==''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai";
  55. if(t[]!=''&&t[]==''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai ling "+num[t[]-''];
  56. if(t[]==''&&t[]!=''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai "+num[t[]-'']+" Shi";
  57. if(t[]!=''&&t[]!=''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai "+num[t[]-'']+" Shi "+num[t[]-''];
  58. }
  59. }
  60.  
  61. int main()
  62. {
  63. cin>>tmp;
  64. int len=tmp.length();
  65. for(int i=;i<len/;i++)
  66. swap(tmp[i],tmp[len-i-]);
  67.  
  68. if(tmp[tmp.length()-]=='-') ans=ans+"Fu ";
  69.  
  70. for(int i=;i<tmp.length();i++)
  71. {
  72. if(tmp[i]=='-') continue;
  73. else s=s+tmp[i];
  74. }
  75.  
  76. if(s.length()==)
  77. {
  78. string s1,s2,s3;
  79.  
  80. string g="";
  81. g=g+s[]+s[]+s[]+s[];
  82. s2=f(g);
  83.  
  84. g="";
  85. g=g+s[]+s[]+s[]+s[];
  86. s3=f(g);
  87.  
  88. ans=ans+num[s[s.length()-]-'']+" Yi";
  89.  
  90. if(s2=="ling") {}
  91. else
  92. {
  93. ans=ans+" ";
  94. if(s[]=='') ans=ans+"ling ";
  95. ans=ans+s2;
  96. ans=ans+" Wan";
  97. }
  98.  
  99. if(s3=="ling"){}
  100. else
  101. {
  102. ans=ans+" ";
  103. if(s[]=='') ans=ans+"ling ";
  104. ans=ans+s3;
  105. }
  106. }
  107. else if(s.length()>=&&s.length()<=)
  108. {
  109. string s2;
  110. string s3;
  111.  
  112. int len=s.length();
  113. for(int i=len;i<;i++) s=s+'';
  114.  
  115. string g;
  116. g=g+s[]+s[]+s[]+s[];
  117. s2=f(g);
  118.  
  119. g="";
  120. g=g+s[]+s[]+s[]+s[];
  121. s3=f(g);
  122.  
  123. ans=ans+s2;
  124. ans=ans+" Wan";
  125.  
  126. if(s3=="ling"){}
  127. else
  128. {
  129. ans=ans+" ";
  130. if(s[]=='') ans=ans+"ling ";
  131. ans=ans+s3;
  132. }
  133.  
  134. }
  135. else if(s.length()<=)
  136. {
  137. string s3;
  138.  
  139. int len=s.length();
  140. for(int i=len;i<;i++) s=s+'';
  141.  
  142. string g;
  143. g=g+s[]+s[]+s[]+s[];
  144. s3=f(g);
  145.  
  146. ans=ans+s3;
  147. }
  148.  
  149. cout<<ans<<endl;
  150.  
  151. return ;
  152. }

PAT (Advanced Level) 1082. Read Number in Chinese (25)的更多相关文章

  1. PTA (Advanced Level)1082.Read Number in Chinese

    Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese ...

  2. 【PAT甲级】1082 Read Number in Chinese (25 分)

    题意: 输入一个九位整数,输出它的汉字读法(用拼音表示). trick: 字符串数组""其实会输出一个空格,而不是什么都不输出,导致测试点0和4格式错误. AAAAAccepted ...

  3. PAT (Advanced Level) 1024. Palindromic Number (25)

    手动模拟加法高精度. 注意:如果输入数字的就是回文,这个时候输出0步. #include<iostream> #include<cstring> #include<cma ...

  4. PAT (Advanced Level) Practise - 1094. The Largest Generation (25)

    http://www.patest.cn/contests/pat-a-practise/1094 A family hierarchy is usually presented by a pedig ...

  5. 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 ...

  6. 1082. Read Number in Chinese (25)-字符串处理

    题意就是给出9位以内的数字,按照汉子的读法读出来. 读法请看下方的几个例子: 5 0505 0505 伍亿零伍佰零伍万零伍佰零伍 5 5050 5050 伍亿伍仟零伍拾万伍仟零伍拾  (原本我以为这个 ...

  7. 1082 Read Number in Chinese (25分)

    // 1082.cpp : 定义控制台应用程序的入口点. // #include <iostream> #include <string> #include <vecto ...

  8. PAT (Advanced Level) 1102. Invert a Binary Tree (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT (Advanced Level) 1098. Insertion or Heap Sort (25)

    简单题.判断一下是插排还是堆排. #include<cstdio> #include<cstring> #include<cmath> #include<ve ...

随机推荐

  1. PHP中GD库安装

    安装gd库扩展不能像其他扩展安装一样,直接./configure --prefix=/xxx 还需要激活png,jpeg,字库等支持 ./configure --prefix=/xxx --with- ...

  2. Django Template模板

    Django Template 你可能已经注意到我们在例子视图中返回文本的方式有点特别. 也就是说,HTML被直接硬编码在 Python 代码之中. 下面我们来调用html views def ind ...

  3. Spring 读取XML配置文件的两种方式

    import org.springframework.context.ApplicationContext; import org.springframework.context.support.Cl ...

  4. 简单粗暴的“Debug模式”

    在项目中,通常会遇到:调试程序和程序在线上运行时程序运行的参数不一样, 例如线上运行时程序是获取线上的机器的ip,而调试程序时,我们会指定一个ip进行调试. 又或者项目要与多个系统进行数据交换,调试的 ...

  5. 【servlet】 过滤器模板

    EncodingFilter.java package Filter; import java.io.IOException; import javax.servlet.Filter; import ...

  6. 多线程junit单元测试

    junit中测试完成后会进行jvm退出,而不是线程退出,所以任一线程退出都会导致测试结束,junit想进行多线程测试需要进行另外包装,网上看到一个投机取巧的例子还不错,贴上我的测试代码(代码中我需要测 ...

  7. Goods transportation

    Goods transportation time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  8. 创建zend framework 项目要注意的

    1.必须要设置变量环境 我的电脑右击-属性-高级-环境变量 则在环境变量中添加 变量名:PATH 环境值:D:\phpserver\php5.4;D:\ZendFramework\bin 把php.e ...

  9. SimplePath 使用心得

    上图是 用SimplePath 做的 寻路,其中 三个 绿点 是 移动的 目标点,三个红点 是 角色移动,蓝色方块是阻挡物体. 这三个角色 移动 有三种 方式,1 随机移动2 按照 绿色小球点 移动  ...

  10. C4.5算法总结

    C4.5是一系列用在机器学习和数据挖掘的分类问题中的算法.它的目标是监督学习:给定一个数据集,其中的每一个元组都能用一组属性值来描述,每一个元组属于一个互斥的类别中的某一类.C4.5的目标是通过学习, ...