| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1967 人关注过本帖
标题:输出框有些问题,求教
取消只看楼主 加入收藏
专业课的小白
Rank: 1
等 级:新手上路
威 望:1
帖 子:56
专家分:0
注 册:2019-12-17
结帖率:40%
收藏
 问题点数:0 回复次数:3 
输出框有些问题,求教
#include<stdio.h>
void main()
{
    float s;
    int x;
    printf("此程序可以实现大小写的转换\n请输入阿拉伯数字:");
    scanf("%d\n",&s);
    x=s*100/10000000000;
    if(x==0)
    {
        x=s*100/1000000000;
        if(x==0)
        {
            x=s*100/100000000;
            if(x==0)
            {
                x=s*100/10000000;
                if(x==0)
                {
                    x=s*100/1000000;
                    if(x==0)
                    {
                        x=s*100/100000;
                        if(x==0)
                        {
                        x=s*100/10000;
                        if(x==0)
                        {
                            x=s*100/1000;
                            if(x==0)
                            {
                                x=s*100/100;
                                if(x==0)
                                {
                                    x=s*100/10;
                                    if(x==0)
                                    {
                                        x=s*100/1;
                                            if(x==0)
                                            {
                                                printf(" ");
                                            }
                                            else
                                            {
                                                if(x==1)
                                                    printf("壹分");
                                                if(x==2)
                                                    printf("贰分");
                                                if(x==3)
                                                    printf("叁分");
                                                if(x==4)
                                                    printf("肆分");
                                                if(x==5)
                                                    printf("伍分");
                                                if(x==6)
                                                    printf("陆分");
                                                if(x==7)
                                                    printf("柒分");
                                                if(x==8)
                                                    printf("捌分");
                                                if(x==9)
                                                    printf("玖分");
                                            }
                                    }
                                    else
                                    {
                                        if(x==1)
                                            printf("壹角");
                                        if(x==2)
                                            printf("贰角");
                                        if(x==3)
                                            printf("叁角");
                                        if(x==4)
                                            printf("肆角");
                                        if(x==5)
                                            printf("伍角");
                                        if(x==6)
                                            printf("陆角");
                                        if(x==7)
                                            printf("柒角");
                                        if(x==8)
                                            printf("捌角");
                                        if(x==9)
                                            printf("玖角");
                                    }
                                }
                                else
                                {
                                    if(x==1)
                                        printf("壹元");
                                    if(x==2)
                                        printf("贰元");
                                    if(x==3)
                                        printf("叁元");
                                    if(x==4)
                                        printf("肆元");
                                    if(x==5)
                                        printf("伍元");
                                    if(x==6)
                                        printf("陆元");
                                    if(x==7)
                                        printf("柒元");
                                    if(x==8)
                                        printf("捌元");
                                    if(x==9)
                                        printf("玖元");
                                }
                            }
                            if(x==1)
                                printf("壹佰");
                            if(x==2)
                                printf("贰佰");
                            if(x==3)
                                printf("叁佰");
                            if(x==4)
                                printf("肆佰");
                            if(x==5)
                                printf("伍佰");
                            if(x==6)
                                printf("陆佰");
                            if(x==7)
                                printf("柒佰");
                            if(x==8)
                                printf("捌佰");
                            if(x==9)
                                printf("玖佰");
                        }
                        else
                        {
                            if(x==1)
                                printf("壹佰");
                            if(x==2)
                                printf("贰佰");
                            if(x==3)
                                printf("叁佰");
                            if(x==4)
                                printf("肆佰");
                            if(x==5)
                                printf("伍佰");
                            if(x==6)
                                printf("陆佰");
                            if(x==7)
                                printf("柒佰");
                            if(x=8)
                                printf("捌佰");
                            if(x==9)
                                printf("玖佰");
                        }
                        }
                        else
                        {
                            if(x==1)
                                printf("壹仟");
                            if(x==2)
                                printf("贰仟");
                            if(x==3)
                                printf("叁仟");
                            if(x==4)
                                printf("肆仟");
                            if(x==5)
                                printf("伍仟");
                            if(x==6)
                                printf("陆仟");
                            if(x==7)
                                printf("柒仟");
                            if(x==8)
                                printf("捌仟");
                            if(x==9)
                                printf("玖仟");
                                 
                        }   
                    }
                    else
                    {
                        if(x==1)
                            printf("壹萬");
                        if(x==2)
                            printf("贰萬");
                        if(x==3)
                            printf("叁萬");
                        if(x==4)
                            printf("肆萬");
                        if(x=5)
                            printf("伍萬");
                        if(x==6)
                            printf("陆萬");
                        if(x==7)
                            printf("柒萬");
                        if(x==8)
                            printf("捌萬");
                        if(x==9)
                            printf("玖萬");
                        
                    }
                }
                else
                {
                    if(x==1)
                        printf("壹拾萬");
                    if(x==2)
                        printf("贰拾萬");
                    if(x==3)
                        printf("叁拾萬");
                    if(x==4)
                        printf("肆拾萬");
                    if(x==5)
                        printf("伍拾萬");
                    if(x==6)
                        printf("陆拾萬");
                    if(x==7)
                        printf("柒拾萬");
                    if(x==8)
                        printf("捌拾萬");
                    if(x==9)
                        printf("玖拾萬");
                    
                }
            }
            else
            {
                if(x==1)
                    printf("壹佰萬");
                if(x==2)
                    printf("贰佰萬");
                if(x==3)
                    printf("叁佰萬");
                if(x==4)
                    printf("肆佰萬");
                if(x==5)
                    printf("伍佰萬");
                if(x==6)
                    printf("陆佰萬");
                if(x==7)
                    printf("柒佰萬");
                if(x==8)
                    printf("捌佰萬");
                if(x==9)
                    printf("玖佰萬");
            }

        }
        else
        {
            if(x==1)
                printf("壹仟萬");
            if(x==2)
                printf("贰仟萬");
            if(x==3)
                printf("叁仟萬");
            if(x==4)
                printf("肆仟萬");
            if(x==5)
                printf("伍仟萬");
            if(x==6)
                printf("陆仟萬");
            if(x==7)
                printf("柒仟萬");
            if(x==8)
                printf("捌仟萬");
            if(x==9)
                printf("玖仟萬");
        }
    }
    else
    {
        if(x==1)
            printf("壹亿");
        if(x==2)
            printf("贰亿");
        if(x==3)
            printf("叁亿");
        if(x==4)
            printf("肆亿");
        if(x==5)
            printf("伍亿");
        if(x==6)
            printf("陆亿");
        if(x==7)
            printf("柒亿");
        if(x==8)
            printf("捌亿");
        if(x==9)
            printf("玖亿");
    }
}
搜索更多相关主题的帖子: 输入 输出 printf 转换 大小写 
2019-12-17 09:35
专业课的小白
Rank: 1
等 级:新手上路
威 望:1
帖 子:56
专家分:0
注 册:2019-12-17
收藏
得分:0 
回复 2楼 bcbbcclbbc
谢谢你回复我,我这个程序的目的是大小写的转换,就是从阿拉伯数字转到繁体的汉字,类似于银行收据之类的,我的问题是:当我输入阿拉伯数字的时候,我按回车它就不输出了,没有反应了。该怎么解决?
2019-12-17 14:10
专业课的小白
Rank: 1
等 级:新手上路
威 望:1
帖 子:56
专家分:0
注 册:2019-12-17
收藏
得分:0 
回复 4楼 bcbbcclbbc
#include<stdio.h>
#include<math.h>
int main()
{
    double s,j;
    int i,q,g;
    char*a[]={"壹","贰","叁","肆","伍","陆","柒","捌","玖"};
    char*b[]={"元","拾","佰","仟","萬","拾","佰","仟","亿"};
    char*d[]={"角","分"};
    for( ; ; )
    {        
        printf("此程序用于实现大小写的转换\n您输入阿拉伯数字,我们将为您转换为汉字\n请输入阿拉伯数字:\n");
        scanf("%lf",&s);
        i=12;
        for(q=i-1;q>=0;q--)
        {
            j=s/pow(10,q);
            g=(int)j%10;
            if(g!=0)
                printf("%s%s",a[g-1],b[q]);
        }
        for(q=-1;q>=-2;q--)
        {
             j=s/pow(10,q);
            g=(int)j%10;
                if(g!=0)
                    printf("%s%s",a[g-1],d[-q-1]);
            }
        printf("\n\n");
    }
}
2019-12-19 11:03
专业课的小白
Rank: 1
等 级:新手上路
威 望:1
帖 子:56
专家分:0
注 册:2019-12-17
收藏
得分:0 
回复 4楼 bcbbcclbbc
那这样是不是简洁一些,但是我的输出有错误,如果我输到亿位,就会有错误
2019-12-19 11:05
快速回复:输出框有些问题,求教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048187 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved