模拟题。

#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. Qt学习之系列[9] – QCoreApplication:processEvents()可能会引起递归,导致栈溢出崩溃

    api含义:QCoreApplication::processEvents() 将处理所有事件队列中的事件并返回给调用者. 问题描述: 当主线程在某个槽函数里正在执行processEvents时, 刚 ...

  2. CLR 无法从 COM

    上下文 0x50ece80 转换为 COM 上下文 0x50ecf38,这种状态已持续 60 秒.拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个 ...

  3. linux 文件系统操作()

    1. 用Xshell 客户端连上远程主机. 2.ll 或 ls 查看当前目录下的文件或目录, cd / 切换到根目录, cd **切换到某个目录(或者叫进入某个文件夹) 3.文件的压缩命令:zip - ...

  4. 【经典dp】 poj 3671

    开一个dp[30010][3]的数组 其中dp[i][j]表示把第i个数改成j最少要花多少次 那么状态转移方程就列出来了: 令a=1 j!=a[i] 0 j==a[i] 那么dp[i][1]=dp[i ...

  5. kinect for windows - DepthBasics-D2D详解

    引自:http://blog.csdn.net/itcastcpp/article/details/20282667 Depth在kinect中经常被翻译为深度图,指的是图像到摄像头的距离,这些距离数 ...

  6. vps安装wordpress遇到的问题(lnmp)

    1.要执行请求的操作,WordPress 需要访问您网页服务器的权限. 请输入您的 FTP 登录XXXX完美解决方法 因为在wordpress中新上传的插件的权限都是www用户的,而不是root或其他 ...

  7. json的学习笔记

    json比较简单,所以先从json开始学起. 一 json的名称: json的全称是javascript object notation,中文名称为js 对象表示法. json的定义:json是一种轻 ...

  8. iOS 2.0 版本切入点

    转载自:http://www.infoq.com/cn/articles/Version_2_0 移动互联网如火如荼,iOS 应用+ Android 应用+ 手机站似乎成了所有互联网公司的标配,你的网 ...

  9. 网络获取的XML的Pull解析

    <?xml version="1.0" encoding="utf-8" ?> - <students> - <student x ...

  10. 添加以及删除className

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...