标题:vc模拟银行常用打印程序,哪错了?
取消只看楼主
初学者请指教
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-5-10
结帖率:0
已结贴  问题点数:20 回复次数:0 
vc模拟银行常用打印程序,哪错了?
#include<stdio.h>
int main()
{
    char Number[128];
    char Interger[64],Decimal[64];
    int lenI,lenD;
    int i,j;
    void PrintInterger(char a[],int len);
    void PrintDecimal(char a[],int len);
    puts("********************************\n");
    puts("*  this is a print program   *\n");
    puts("*     used in a bank         *\n");
    puts("********************************\n");
    puts("please input the money:");
    gets(Number);
    i=0;j=0;
    while((Number[i]!='\0')&&(Number[i]!='.'))
    {
        Interger[i]=Number[i];
        i++;
    }
    lenI=i;
    PrintInterger(Interger,lenI);
    if(Number[i]=='.')
    {
        i++;
        while(Number[i]!='\0')
            Decimal[j++]=Number[i++];
        if((j>=4)&&(Decimal[4]>='5'))
        {   
            Decimal[3]+=1;
            Decimal[4]='\0';
        }
    if(j>=4)
        lenD=4;
    else
        lenD=j;
    PrintDecimal(Decimal,lenD);
    }
    getchar();
    return 0;
}
void PrintInterger(char a[],int len)
{
    int i,j;
    printf("你的钱数是: \n");
    for(i=0,j=len-1;(a[i]!='.')&&(a[i]!='\0');i++,j--)
    {
        switch(a[i])
        {
        case'0':
            {
                do
                {
                    i++;
                    j--;
                }while(a[i]!=0);
                printf("%s","零");
                break;
            }
        case'1':
            printf("%s","壹");break;
        case'2':
            printf("%s","贰");break;
        case'3':
            printf("%s","叁");break;
        case'4':
            printf("%s","肆");break;
        case'5':
            printf("%s","伍");break;
        case'6':
            printf("%s","陆");break;
        case'7':
            printf("%s","柒");break;
        case'8':
            printf("%s","捌");break;
        case'9':
            printf("%s","玖");break;
        default:
            printf("error");break;
        }
        switch(j)
        {
        case'1':
            printf("%s","个");break;
        case'2':
            printf("%s","十");break;
        case'3':
            printf("%s","百");break;
        case'4':
            printf("%s","千");break;
        case'5':
            printf("%s","万");break;
        case'6':
            printf("%s","十万");break;
        case'7':
            printf("%s","百万");break;
        case'8':
            printf("%s","千万");break;
        case'9':
            printf("%s","忆");break;
        default:
            printf("%s",' ');break;
        }
    }
}
void PrintDecimal(char a[],int len)
{
    int i;
    for(i=0;i<=len;i++)
    {
        switch(a[i])
        {
        case'0':
            printf("%s","零");break;
        case'1':
            printf("%s","壹");break;
        case'2':
            printf("%s","贰");break;
        case'3':
            printf("%s","叁");break;
        case'4':
            printf("%s","肆");break;
        case'5':
            printf("%s","伍");break;
        case'6':
            printf("%s","陆");break;
        case'7':
            printf("%s","柒");break;
        case'8':
            printf("%s","捌");break;
        case'9':
            printf("%s","玖");break;
        default:
            printf("error");break;
        }
        switch(a[i])
        {
        case'0':
            printf("%s","零");break;
        case'1':
            printf("%s","壹");break;
        case'2':
            printf("%s","贰");break;
        case'3':
            printf("%s","叁");break;
        case'4':
            printf("%s","肆");break;
        }
    }
}
哪错了,求大神指教
搜索更多相关主题的帖子: include please money 
2013-05-14 12:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407038-1-1.html




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

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