模拟题。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std; string num[]=
{
"ling","yi","er","san","si",
"wu","liu","qi","ba","jiu"
};
string tmp="";
string ans="";
string s=""; string f(string TMP)
{
if(TMP[]==''&&TMP[]==''&&TMP[]==''&&TMP[]=='') return "ling";
string t="";
int p;
for(int i=TMP.length()-;i>=;i--)
if(TMP[i]!='') {p=i; break;} for(int i=;i<=p;i++) t=t+TMP[i]; if(t=="" ) return "ling"; if(t.length()==) return "ling";
if(t.length()==) return num[t[]-''];
if(t.length()==)
{
if(t[]=='') return num[t[]-'']+" Shi";
return num[t[]-'']+" shi "+num[t[]-''];
}
if(t.length()==)
{
if(t[]==''&&t[]=='') return num[t[]-'']+" Bai";
if(t[]==''&&t[]!='') return num[t[]-'']+" Bai "+num[t[]-'']+" Shi";
if(t[]!=''&&t[]=='') return num[t[]-'']+" Bai ling "+num[t[]-''];
if(t[]!=''&&t[]!='') return num[t[]-'']+" Bai "+num[t[]-'']+" Shi "+num[t[]-''];
}
if(t.length()==)
{
if(t[]==''&&t[]==''&&t[]=='') return num[t[]-'']+" Qian";
if(t[]!=''&&t[]==''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-''];
if(t[]==''&&t[]!=''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-'']+" Shi";
if(t[]!=''&&t[]!=''&&t[]=='') return num[t[]-'']+" Qian ling "+num[t[]-'']+" Shi "+num[t[]-''];
if(t[]==''&&t[]==''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai";
if(t[]!=''&&t[]==''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai ling "+num[t[]-''];
if(t[]==''&&t[]!=''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai "+num[t[]-'']+" Shi";
if(t[]!=''&&t[]!=''&&t[]!='') return num[t[]-'']+" Qian "+num[t[]-'']+" Bai "+num[t[]-'']+" Shi "+num[t[]-''];
}
} int main()
{
cin>>tmp;
int len=tmp.length();
for(int i=;i<len/;i++)
swap(tmp[i],tmp[len-i-]); if(tmp[tmp.length()-]=='-') ans=ans+"Fu "; for(int i=;i<tmp.length();i++)
{
if(tmp[i]=='-') continue;
else s=s+tmp[i];
} if(s.length()==)
{
string s1,s2,s3; string g="";
g=g+s[]+s[]+s[]+s[];
s2=f(g); g="";
g=g+s[]+s[]+s[]+s[];
s3=f(g); ans=ans+num[s[s.length()-]-'']+" Yi"; if(s2=="ling") {}
else
{
ans=ans+" ";
if(s[]=='') ans=ans+"ling ";
ans=ans+s2;
ans=ans+" Wan";
} if(s3=="ling"){}
else
{
ans=ans+" ";
if(s[]=='') ans=ans+"ling ";
ans=ans+s3;
}
}
else if(s.length()>=&&s.length()<=)
{
string s2;
string s3; int len=s.length();
for(int i=len;i<;i++) s=s+''; string g;
g=g+s[]+s[]+s[]+s[];
s2=f(g); g="";
g=g+s[]+s[]+s[]+s[];
s3=f(g); ans=ans+s2;
ans=ans+" Wan"; if(s3=="ling"){}
else
{
ans=ans+" ";
if(s[]=='') ans=ans+"ling ";
ans=ans+s3;
} }
else if(s.length()<=)
{
string s3; int len=s.length();
for(int i=len;i<;i++) s=s+''; string g;
g=g+s[]+s[]+s[]+s[];
s3=f(g); ans=ans+s3;
} cout<<ans<<endl; return ;
}

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. mysql日志详细解析【转载】

    转自:http://pangge.blog.51cto.com/6013757/1319304 MySQL日志: 主要包含:错误日志.查询日志.慢查询日志.事务日志.二进制日志: 日志是mysql数据 ...

  2. /etc/rc.local 与 /etc/init.d Linux 开机自动运行程序

    1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里 --------引用---------------------- 在完成 run level 3 ...

  3. Linq List<String>

    List<string> _year = new List<string>() { "一月", "二月", "三月" ...

  4. replication factor

    http://www.tuicool.com/articles/RJbIBj 关于Hadoop中replication factor解惑 时间 2014-06-09 08:00:50   ITeye ...

  5. wpf绑定之格式化日期

    只显示年月日: StringFormat='{}{0:yyyy/MM/dd}' 又或者: StringFormat='{}{0:yyyy年MM月dd日 dddd HH:mm:ss}',Converte ...

  6. 直接用postman测试api ,服务器端没提供跨域也可以访问。

    1. 直接用postman测试api ,服务器端没提供跨域也可以访问. 但是,如果用本地的 sever 搭的server, 然后去访问api的话,浏览器会提示 跨域错误.

  7. LightOJ 1030 Discovering Gold 数学期望计算

    题目大意:给出长度为n的一条隧道,每个位置都有一定数量的财宝.给你一枚骰子,roll到几点就前进几步,如果即将到达的地方超过了这条隧道长度,就重新roll一次,走到n点结束.求这个过程能收获多少财宝. ...

  8. linux视频学习3(linux安装,shell,tcp/ip协议,网络配置)

    linux系统的安装: 1.linux系统的安装方式三种: 1.独立安装linux系统. 2.虚拟机安装linux系统. a.安装虚拟机,基本是一路点下去. b.安装linux. c.linux 安装 ...

  9. Top 100 Best Blogs for iOS Developers

    (by JP Zhang | Last updated: Apr 5, 2016 )  转载自:http://www.softwarehow.com/best-blogs-for-ios-develo ...

  10. iframe2016/4/12

    js操作iframe contentWindow    在服务器环境下测试contentDocument二种方法的区别子级iframe修改父级元素内容window.parentwindow.top与w ...