题意:

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

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. Oracle Linux安装

    注:Oracle11gR2 X64安装 一.环境准备 安装包: 2.CentOS-7-x86_64-DVD-1511.iso 3.linux.x64_11gR2_database_1of2.zip l ...

  2. HITCON-Training-Writeup

    HITCON-Training-Writeup 原文链接M4x@10.0.0.55 项目地址M4x's github,欢迎star~ 更新时间5月16 复习一下二进制基础,写写HITCON-Train ...

  3. 【转载】 __declspec(dllexport) 和__declspec(dllimport)

    转自:http://www.cppblog.com/Dutyboy/archive/2010/11/15/133699.html __declspec(dllexport)   __declspec( ...

  4. Jarvis OJ - 栈系列部分pwn - Writeup

    最近做了Jarvis OJ的一部分pwn题,收获颇丰,现在这里简单记录一下exp,分析过程和思路以后再补上 Tell Me Something 此题与level0类似,请参考level0的writeu ...

  5. 转载一篇棒棒的AWK教程

    处理文件经常要用到awk,老是找同事帮忙,次数多了难免被吐槽orz,其实之前也有找过awk的教程,表示一直看不太懂 最近翻到了这篇教程,表示笔者真的太棒了,反正我是看一遍就懂了哈哈 剩下的只是熟悉度的 ...

  6. json字符串和object之间的相互转化

    package asi; import java.util.ArrayList; import com.alibaba.fastjson.JSON; import com.alibaba.fastjs ...

  7. L1-7 谁是赢家

    思路 这题好简单,可以分析一下,没有别的情况了. 代码 #include <bits/stdc++.h> using namespace std; int main() { int p1, ...

  8. [MC] 我的世界 craftbukkit-1.12.2 卡爆

    昨天晚上的时候,和朋友玩我的世界 结果我这边卡爆了,牛圈里面的牛都是一动一动的... 然后我登陆服务器,发现CPU爆炸了... 100%的使用率 mstsc都卡爆了 内存占用了800多MB (服务器是 ...

  9. span标签间距

    最近在做的一个项目里面碰到这么一个问题: <p> <span>块1</span> <span>块2</span> </p> 在“ ...

  10. Sliding Window POJ - 2823 单调队列模板题

    Sliding Window POJ - 2823 单调队列模板题 题意 给出一个数列 并且给出一个数m 问每个连续的m中的最小\最大值是多少,并输出 思路 使用单调队列来写,拿最小值来举例 要求区间 ...