题意:

输入一个九位整数,输出它的汉字读法(用拼音表示)。

trick:

字符串数组""其实会输出一个空格,而不是什么都不输出,导致测试点0和4格式错误。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int num[];
string united[]={"","yi","er","san","si","wu","liu","qi","ba","jiu"};
string unit[]={"","","Shi","Bai","Qian","Wan","Shi","Bai","Qian"};
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x;
cin>>x;
if(x<){
cout<<"Fu ";
x=-x;
}
else if(x==){
cout<<"ling";
return ;
}
int tamp=;
for(int i=;i<=;++i)
tamp*=;
for(int i=;i;--i){
num[i]=x/tamp;
x%=tamp;
tamp/=;
}
int space=;
if(num[])
cout<<united[num[]]<<" Yi",space=;
int pos=;
for(int i=;i;--i)
if(num[i]){
pos=i;
break;
}
int ling=;
if(num[]&&pos<)
ling=;
for(int i=pos;i;--i){
if(num[i]){
if(space)
cout<<" ",space=;
if(ling)
cout<<"ling",ling=,space=;
if(space)
cout<<" ",space=;
cout<<united[num[i]],space=;
if(i!=&&i!=){
if(space)
cout<<" ",space=;
cout<<unit[i],space=;
}
}
else if(!ling&&i!=)
ling=;
if(i==){
if(space)
cout<<" ",space=;
cout<<"Wan",space=;
}
}
return ;
}

【PAT甲级】1082 Read Number in Chinese (25 分)的更多相关文章

  1. 1082 Read Number in Chinese (25分)

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

  2. A1082 Read Number in Chinese (25 分)

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

  3. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  4. PAT甲级:1089 Insert or Merge (25分)

    PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...

  5. PAT 甲级 1145 Hashing - Average Search Time (25 分)(读不懂题,也没听说过平方探测法解决哈希冲突。。。感觉题目也有点问题)

    1145 Hashing - Average Search Time (25 分)   The task of this problem is simple: insert a sequence of ...

  6. PAT 甲级 1066 Root of AVL Tree (25 分)(快速掌握平衡二叉树的旋转,内含代码和注解)***

    1066 Root of AVL Tree (25 分)   An AVL tree is a self-balancing binary search tree. In an AVL tree, t ...

  7. PAT 甲级 1055 The World's Richest (25 分)(简单题,要用printf和scanf,否则超时,string 的输入输出要注意)

    1055 The World's Richest (25 分)   Forbes magazine publishes every year its list of billionaires base ...

  8. PAT 甲级 1047 Student List for Course (25 分)(cout超时,string scanf printf注意点,字符串哈希反哈希)

    1047 Student List for Course (25 分)   Zhejiang University has 40,000 students and provides 2,500 cou ...

  9. PAT 甲级 1039 Course List for Student (25 分)(字符串哈希,优先队列,没想到是哈希)*

    1039 Course List for Student (25 分)   Zhejiang University has 40000 students and provides 2500 cours ...

随机推荐

  1. C++——一维数组

    6.数组 指针与字符串 6.1 数组 数组是具有一定顺序关系的若干相同类型变量的集合体,组成数组的变量成为数组的元素.数组属于构造类型. 一维数组的声明: 类型说明符 数组名[常量表达式],若int ...

  2. python3练习100题——022

    为了周末轻松点,多做一些题. 原题链接:http://www.runoob.com/python/python-exercise-example22.html 题目:两个乒乓球队进行比赛,各出三人.甲 ...

  3. Dapper简介

    Dapper文档 一,介绍:Dapper是一款轻量级ORM工具.如果你在小的项目中,使用Entity Framework.NHibernate 来处理大数据访问及关系映射,未免有点杀鸡用牛刀.你又觉得 ...

  4. js基础心得

    最近有想法研究jQuery源码,一顿查阅顿感自己基础薄弱.手中正好有一本js高程,遂决定深入js基础,并记录心得至博客园.以待一举攻克jQuery,VUE等源码. 1,变量.作用域和内存问题 2,引用 ...

  5. CAN总线电平(隐性与显性)

            CAN2.0B规范定义了两种互补的逻辑数值:显性和隐性.同时传送显性和隐性位时,总线呈现显性状态:同时传送显性状态位时,总线呈现显性状态:同时传送隐性状态位时,总线呈现隐性状态.显性数 ...

  6. 什么是文件的BOM头,及BOM头有哪些坑?

    1.什么是BOM? BOM是用来判断文本文件是哪一种Unicode编码的标记,其本身是一个Unicode字符("\uFEFF"),位于文本文件头部. 在不同的Unicode编码中, ...

  7. 常用统计分析python包开源学习代码 numpy pandas matplotlib

    常用统计分析python包开源学习代码 numpy pandas matplotlib 待办 https://github.com/zmzhouXJTU/Python-Data-Analysis

  8. ES6新的数据类型 generato,在AJAX中的应用

    1.next()方法会执行generator的代码,然后,每次遇到yield x;就返回一个对象{value: x, done: true/false},然后“暂停”.返回的value就是yield的 ...

  9. Rabbitmq consumer端超时报错

    0x01 应用场景: 使用rabbitmq的exchange模式,type为direct,消费端不需要向生产端返回结果no_ack=True 其中某个consumer任务耗时较长(5min以上),结果 ...

  10. springboot引入Oracle依赖

    最近学习spring boot,在网上找一些项目学习,有的项目引入了oracle驱动包,自己搭建一直不成功,百度发现说是权限问题无法下载. 然后参考下面博客终于解决:springboot引入Oracl ...