题意:

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

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. How to Create an OCM Response file to Apply a Patch in Silent Mode - opatch silent

    Windows Server 2019 打补丁时缺少Oracle Configuration Manager(OCM) 响应文件处理方式. 适用: Oracle Universal Installer ...

  2. STL-C - 稳定排序

    C - 稳定排序 大家都知道,快速排序是不稳定的排序方法.如果对于数组中出现的任意a[i],a[j](i<j),其中a[i]==a[j],在进行排序以后a[i]一定出现在a[j]之前,则认为该排 ...

  3. 托管代码中调用c++本地代码

    c++本地动态连接库代码 #pragma once #include "stdafx.h" #ifdef PERSON_EXPORTS #define PERSON_API __d ...

  4. 未能加载文件或程序集“Autofac.Integration.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

    是因为web.config中dependentAssembly结点下的版本号和当前引用的程序集的版本号不一致!

  5. 1015 Reversible Primes

    1. 题目 2. 抽象建模 无 3. 方法 无 4. 注意点 素数判断(1不是素数) 数值的倒转 5. 代码 #include<stdio.h> #include<math.h> ...

  6. c++中sort函数调用报错Expression : invalid operator <的内部原理 及解决办法

    转自:https://www.cnblogs.com/huoyao/p/4248925.html 当我们调用sort函数进行排序时,中的比较函数如果写成如下 bool cmp(const int &a ...

  7. Java 数据库树形查询生成菜单结构

    Java 数据库树形查询 JAVA从数据库读取菜单,递归生成菜单树. 定义菜单类 public class Menu { // 菜单id private String id; // 菜单名称 priv ...

  8. Attribute "resultType" must be declared for element type "update" or "insert"

    仔细查看错误如图所示: 解决错误就是把resultType去掉,因为在insert和update语句中是没有返回值的.小坑小坑 转自:https://blog.csdn.net/u013144287/ ...

  9. 210. 课程表 II

    Q: 现在你总共有 n 门课需要选,记为 0 到 n-1. 在选修某些课程之前需要一些先修课程. 例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹配来表示他们: [0,1] 给定课程总量 ...

  10. c++基础语法规则

    1,c++存储类:定义函数或者变量的生命周期     auto 关键字用于两种情况:声明变量时根据初始化表达式自动推断该变量的类型.声明函数时函数返回值的占位符. register 存储类用于定义存储 ...