#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm> using namespace std; const char* d2cn[] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};
const char* t2cn[] = {"Ge", "Shi", "Bai", "Qian"}; void num2cn(int num, vector<string>& out) {
vector<string> tmp;
int i = ;
int last = ;
while (num) {
int cur = num % ;
if (cur != || last != ) {
if (i != && cur != ) {
tmp.push_back(string(t2cn[i]));
}
tmp.push_back(string(d2cn[cur]));
}
last = cur;
num /= ;
i++;
}
reverse(tmp.begin(), tmp.end());
out.insert(out.end(), tmp.begin(), tmp.end());
} int main() {
vector<string> out;
int N;
scanf("%d", &N);
int num = N;
if (num < ) {
out.push_back("Fu");
num = -num;
} int ds[] = {};
int i = ;
int yi = num / ;
num = num % ;
int wan = num / ;
int ge = num % ; if (yi != ) {
out.push_back(d2cn[yi]);
out.push_back("Yi");
}
if (wan != ) {
if (wan < && yi != ) {
out.push_back("ling");
}
num2cn(wan, out);
out.push_back("Wan");
} if (ge != ) {
if (ge < && (yi | wan)) {
out.push_back("ling");
}
num2cn(ge, out);
}
if (out.size() == ) {
printf("ling");
} else {
printf("%s", out[].c_str());
int len = out.size();
for (int i=; i<len; i++) {
printf(" %s", out[i].c_str());
}
}
printf("\n");
return ;
}

坚持

PAT 1082. Read Number in Chinese的更多相关文章

  1. PAT 1082 Read Number in Chinese[难]

    1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to ...

  2. 1082 Read Number in Chinese (25 分)

    1082 Read Number in Chinese (25 分) Given an integer with no more than 9 digits, you are supposed to ...

  3. PAT (Advanced Level) 1082. Read Number in Chinese (25)

    模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

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

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

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

  7. 1082 Read Number in Chinese

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

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

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

  9. 1082 Read Number in Chinese (25分)

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

随机推荐

  1. jquery事件三 -- load(), ready(), resize()以及bind()事件

    例子1 ready() DOM加载完毕 load() 元素加载完毕 resize() 浏览器窗口的大小发生变化 <!DOCTYPE html> <html lang="en ...

  2. java内存模型(jMM)(一)

    在说java的内存模型之前先简单的了解计算机的主存和缓存的相关概念. 多任务和高并发是衡量一台计算机处理器的重要指标.一般衡量一个服务器性能的高低好坏,使用每秒事务处理数(Transactions P ...

  3. 【洛谷 5002】专心OI - 找祖先 (树上计数)

    专心OI - 找祖先 题目背景 \(Imakf\)是一个小蒟蒻,他最近刚学了\(LCA\),他在手机\(APP\)里看到一个游戏也叫做\(LCA\)就下载了下来. 题目描述 这个游戏会给出你一棵树,这 ...

  4. 使用 WebClient 來存取 GET,POST,PUT,DELETE,PATCH 網路資源

    WebClient 基本資訊 提供通用方法使用 WebRequest 類別傳送及接收 URI (支援 http:, https:, ftp:,和 file: ) 的資源 Namespace:Syste ...

  5. php 返回数组中指定多列的方法

    php array_column 方法可以返回数组中指定的一列,但不能返回多列,本文将介绍array_column方法的使用,并用代码演示返回数组中指定多列的方法. 1.array_column说明 ...

  6. MySQL:管理MySQL、事务(三)

    干货: 命令行程序mysql实际上是MySQL客户端,真正的MySQL服务器程序是mysqld,在后台运行. 数据库事务具有ACID特性,用来保证多条SQL的全部执行. 五.MySQL 通过mysql ...

  7. CDQZ Day2

    模拟题 day2出题人: liu_runda题目名称 一盘大棋 下一代互联网 强连通分量源程序文件名 chess.cpp net.cpp scc.cpp输入文件名 chess.in net.in sc ...

  8. 认识CSS中布局之文档流、浮动、定位以及叠放次序

    前端之HTML,CSS(七) CSS CSS布局的核心就是盒子的摆放,即CSS定位.而CSS中定位机制分为:普通流(nomal flow).浮动(float).定位(position). 普通流 普通 ...

  9. Java操作系统剪贴板(Clipboard)复制粘贴

    Java操作系统剪贴板(Clipboard)复制粘贴

  10. netty总结

    eventLoopGroup中创建各个eventLoop处理线程,各个pipeLineHandler处理childEvent时是在自己的线程中, 全异步