题意:

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

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. vue.js + element中el-select实现拼音匹配,分词、缩写、多音字匹配能力

    1.既然要用到拼音搜索,我们就需要一个拼音库,在这里我推荐一个第三方包:https://github.com/xmflswood/pinyin-match,在这里首先对这个包的开发者表示万分的感谢. ...

  2. mysql之instr函数

    1.用于模糊查询,做为过滤条件 ---------------------------上级的新闻下级可以看到-------------------------SELECT a.pk_cms_nrgl_ ...

  3. 1-Django2.2安装指南

    django快速安装指南 作为一个Python Web框架,Django需要Python环境.下面是Django需要对应的python版本. Django版本 python版本 1.11 2.7, 3 ...

  4. c#中convert.toInt32和int.parse()和强制类型转换的区别

    string a="123"; int i=(int)a; 这是会出现错误因为:强制类型转换只能转换值类型不能转换引用类型 string属于引用类型    强制类型转换时如果值类型 ...

  5. HTML列表标签

    <ul>无序列表 有2个属性 1.compact 属性: 规定列表呈现的效果比正常情况更小巧.没啥作用 2.type 属性 disc小圆点 square小方块 circle小圆圈(默认) ...

  6. mysql之路4

    MYSQL之约束 2.主键约束 349行cnname换成cname

  7. 钉钉内网穿透工具在windows的使用。

    钉钉内网穿透工具在windows环境下使用 1.WIN+R,然后cmd,调出dos控制台 2.进入内网穿透程序ding.exe所在目录 3.执行 ./ding.exe -config=ding.cfg ...

  8. git中全局设置用户名、邮箱

    1.查看git配置信息:git config --list (可以查看所有的配置信息) 2.查看git用户名:git config user.name 3.查看邮箱配置:git config user ...

  9. AC3 bit allocation

    1.bit allocation overview bit allocation通过分析audio 信号的频谱envelop,使用masking effect来确定使用多少bit来表示频率系数的man ...

  10. python+selenium:浏览器webdriver操作(1)--基本对象定位

    1.简单对象的定位-----自动化测试的核心 对象的定位应该是自动化测试的核心,要想操作一个对象,首先应该识别这个对象.一个对象就是一个人一样,他会有各种的特征(属性),如比我们可以通过一个人的身份证 ...