/ 科创班 /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 256.0 KiB
#2 Accepted 2ms 256.0 KiB
#3 Accepted 2ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 2ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB

代码

#include <stdio.h>

int main()
{
    char* num[] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
    char* wei[] = {"shi","bai","qian","wan","yi"};
    char* str[20];
    int n;
    scanf("%d", &n);
    int i = 0, j = 0, k, l[2] = {0};
    while (n > 0)
    {
        k = n % 10;
        n /= 10;
        if (k > 0) {
            if (i > 0)
            {
                if (i >= 4 && !l[i / 4 - 1]) l[i / 4 - 1] = 1, str[j++] = wei[i / 4 + 2];
                if (i % 4 != 0) str[j++] = wei[i % 4 - 1];
            }
            str[j++] = num[k];
        } else if (j > 0 && str[j - 1] != num[0]) {
            str[j++] = num[0];
        }
        i++;
    }
    if (!(str[j - 1] == num[1] && j > 1 && str[j - 2] == wei[0]))
        printf("%s ", str[j - 1]);
    for (i = j - 2; i >= 0; i--)
        printf("%s ", str[i]);
    return 0;
}

信息

递交者
类型
递交
题目
数的读法
题目数据
下载
语言
C
递交时间
2018-10-17 20:24:24
评测时间
2018-10-17 20:24:24
评测机
分数
100
总耗时
16ms
峰值内存
256.0 KiB