求C语言的阿拉伯数字转为其对应英文单词的完整代码 如123 转为one hundred twenty three.

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 17:00:52
求C语言的阿拉伯数字转为其对应英文单词的完整代码 如123 转为one hundred twenty three.
xVn0~+UMoOQz,nc)u8S% !(L\!!6^ɲJ݅>Ο'[7w?x_??LW=og;?2=۪Tn}YPĶl݂pZsF,EDy ua׈ޚ5 5=! tsya/Y\ \;fܒ7;I2`zH^b _f AQG8s%AlY6 1\K N]cJrV4ls%b ADWe`ʖՐɔ_RNi0Ljyj,&)V[<ώ0?VA-_ ֞avHR--sQ<͙,,겳 Jm͇J4Ll.8ΤPW?^9Z3,ClI'po;O'{;=;MχEP{Z

求C语言的阿拉伯数字转为其对应英文单词的完整代码 如123 转为one hundred twenty three.
求C语言的阿拉伯数字转为其对应英文单词的完整代码 如123 转为one hundred twenty three.

求C语言的阿拉伯数字转为其对应英文单词的完整代码 如123 转为one hundred twenty three.
#include<stdio.h>
#include <stdlib.h>
void main()
{
    char *Eng1[20]={"zero","one","two","three","four","five","six","seven",
        "eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen",
        "sixteen","seventeen","eighteen","nineteen"};
    char *Eng2[8]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"};
    int num;
    printf("请输入数字:");
    scanf("%d",&num);
    printf("对应的英文为:");
    if(num>=0&&num<=19)
        printf("%s\n",Eng1[num]);
    else if(num<100)
    {
        int s,y;
        s=num/10;
        y=num%10;
        printf("%s %s\n",Eng2[s-2],Eng1[y]);
    }
    else if(num<1000)
    {
        int b,s,y;
        b=num/100;
        y=num%100;
        if(y>9)
        {
            s=(num%100)/10;
            y=(num%100)%10;
            if(y==0)
                printf("%s hundred and %s\n",Eng1[b],Eng2[s-2]);
            else
                printf("%s hundred and %s %s\n",Eng1[b],Eng2[s-2],Eng1[y]);
        }
        else
            printf("%s hundred and %s\n",Eng1[b],Eng1[y]);
    }
    system("pause");
}
我只是个酱油- -