PAT 甲级 A1082 (2019/02/14)13/25

#include<cstdio>
#include<cstring>
char strnumber[16][5] = {
    "ling", "yi", "er", "san", "si", "wu", "liu", "qi",
    "ba", "jiu", "Ge", "Shi", "Bai", "Qian", "Wan", "Yi"
};
int main(){
    char str[16];
    scanf("%s", str);
    int len = strlen(str);
    int flag = 0;
    if(str[0] == '-') {
        printf("Fu");
        flag = 1;
    }
    //8132345680080898
    int Data[100], top = 0, start1, start2, start3, start4;
    start1 = start2 = start3 = start4 = 10;
    int iswan, isqian, isyi, iswanyi;
    iswan = isqian = isyi = iswanyi = 0;
    for(int i = len-1; flag ? i > 0 : i >= 0; i--){
        if(len == 1){
            Data[top++] = str[i]- '0';
        }else if(i >= len - 4 && i <= len - 1){
            Data[top++] = start1++;
            Data[top++] = str[i] - '0';
        }else if(i >= len - 8 && i <= len - 5){
            if(iswan == 0){
                Data[top++] = 14;
                iswan = 1;
            }
            Data[top++] = start2++;
            Data[top++] = str[i] - '0';
        }else if(i >= len - 12 && i <= len - 9){
            if(isyi == 0){
                Data[top++] = 15;
                isyi = 1;
            }
            Data[top++] = start3++;
            Data[top++] = str[i] - '0';
        }else if(i >= len - 16 && i <= len - 13){
            if(iswanyi == 0){
                Data[top++] = 14;
                iswanyi = 1;
            }
            Data[top++] = start4++;
            Data[top++] = str[i] - '0';
        }
    }
    int sign = 0;
    for(int i = top-1; i > 0; i = i - 1){
        if(Data[i] != 10){
            if(Data[i] == 0){
                i = i - 1;
                continue;
            }
            if(i != top - 1 || str[0] == '-'){
                printf(" %s", strnumber[Data[i]]);
            }else{
                printf("%s", strnumber[Data[i]]);
            }
        }
    }
    return 0;
}

千万亿 百万亿 十万亿 万亿 千亿 百亿 十亿 亿 千万 百万 十万 万 千 百 十 个

234 134 034 34 24 14 04 4 23 13 03 3 2 1 0

8132 3456 8008 0898

ba Qian yi Bai san Shi er Wan

san Qian si Bai wu Shi liu Yi

ba Qian ling ba Wan

ling ba Bai jiu Shi ba

8132345680080898

原文地址:https://www.cnblogs.com/zjsaipplp/p/10425258.html

时间: 2024-09-27 11:53:23

PAT 甲级 A1082 (2019/02/14)13/25的相关文章

PAT 甲级 A1082 (2019/02/14) NULL(12/25)

1 #include<cstdio> 2 #include<cstring> 3 char strnumber[16][5] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu", "Ge&quo

PAT甲级【2019年3月考题】——A1158 TelefraudDetection【25】

Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c

【PAT甲级】1110 Complete Binary Tree (25分)

题意: 输入一个正整数N(<=20),代表结点个数(0~N-1),接着输入N行每行包括每个结点的左右子结点,'-'表示无该子结点,输出是否是一颗完全二叉树,是的话输出最后一个子结点否则输出根节点. trick: 用char输入子结点没有考虑两位数的结点??... stoi(x)可以将x转化为十进制整数 AAAAAccepted code: 1 #define HAVE_STRUCT_TIMESPEC 2 #include<bits/stdc++.h> 3 using namespace

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, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this

PAT 甲级1002 A+B for Polynomials (25)

1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file contains one test case. Each case occupies 2 lines, an

【PAT甲级】1052 Linked List Sorting (25分)

1052 Linked List Sorting (25分) A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, yo

PAT甲级1002.A+B for Polynomials (25)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805526272000000 解题思路: 由于是求两个多项式之和,并且多项式的指数是从大到小进行排列的,相加时有合并和消除的操作 因此选用了较为灵活的链表结构,将输入的第一个多项式使用链表存储起来,将第二个多项式的项依次输入, 对于加数每个项和被加数的每项的指数进行比较,如果大于其指数则插入在其前面,如果小于其指数,则比较 被加数的后一项,如果等于其指数,则将两

2019.02.14

人生呐,要做一个有趣的人,和有趣的人在一起.但有的人自己无趣,却还想对方有趣,唉. 和有趣的人在一起,生活都变得有趣了,比如崔神和小马,看到他们撒狗粮就觉得很甜蜜很好玩,这才是真爱鸭. 今天听妈讲相亲故事,又无奈又无助.确实女生到了一定年龄之后年龄是个bug,再像我们这种没什么姿色与才艺的就更难了,于是一步步往命运屈服,聊着不想聊的天,谈着不想谈的恋爱,形式了所有流程,话语,红包,礼物,唯独缺少了走心.说不出哪里怪,但就是感觉不到温度.或许相亲就是这样吧. 性是人的本性之一,所以大家都喜欢出轨,

【PAT甲级】1044 Shopping in Mars (25 分)(前缀和,双指针)

题意: 输入一个正整数N和M(N<=1e5,M<=1e8),接下来输入N个正整数(<=1e3),按照升序输出"i-j",i~j的和等于M或者是最小的大于M的数段. 代码: #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int a[100007];int sum[100007];vector<pair<int,int> >ans;int m