标题:[求助]关于大小写数字的转换,请高手指点
只看楼主
非凡DZ
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2007-4-6
 问题点数:0 回复次数:1 
[求助]关于大小写数字的转换,请高手指点
请大家帮忙看看 小数点后面为什么会出现问题(小数点后面应该是数组b2里面的内容,可输出时却有数组b1里面的内容)谢谢

#include<stdio.h>
void main()
{
char grade[50];
int i,point;
char *b1[9]={"亿","千","百","十","万","千","百","十","元"};
//char *b1[9]={"元","十","百","千","万","十","百","千","亿"};
char *b2[3]={"角","分","厘"};
//do
//{
printf("请输入金额:");
gets(grade);
//for(i=0;i<50;i++)
//{
//if(grade[i]!='.')
//{
//printf("请输入一个带有小数点的金额!\n");
//break;
//}
//}
//}while(grade[i]!='.');
for(i=0;i<50;i++)
{
if(grade[i]=='.')
{
point=i;
break;
}
}
for(i=0;i<50;i++)
{
if(i<point)
{
switch(grade[i])
{
case '0':
printf("零");
break;
case '1':
printf("壹");
break;
case '2':
printf("贰");
break;
case '3':
printf("叁");
break;
case '4':
printf("肆");
break;
case '5':
printf("伍");
break;
case '6':
printf("陆");
break;
case '7':
printf("柒");
break;
case '8':
printf("捌");
break;
case '9':
printf("玖");
break;
}
printf("%s",b1[i+(9-point)]);
}
}
for(i=0;i<50;i++)
{
if(i>point)
{
switch(grade[i])
{
case '0':
printf("零");
break;
case '1':
printf("壹");
break;
case '2':
printf("贰");
break;
case '3':
printf("叁");
break;
case '4':
printf("肆");
break;
case '5':
printf("伍");
break;
case '6':
printf("陆");
break;
case '7':
printf("柒");
break;
case '8':
printf("捌");
break;
case '9':
printf("玖");
break;
}
printf("%s",b2[i]);
}
}
}
搜索更多相关主题的帖子: 数字 大小写 
2007-04-12 15:04
I喜欢c
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:64
帖 子:1749
专家分:0
注 册:2007-3-2
得分:0 
以下是引用非凡DZ在2007-4-12 15:04:25的发言:
请大家帮忙看看 小数点后面为什么会出现问题(小数点后面应该是数组b2里面的内容,可输出时却有数组b1里面的内容)谢谢

#include<stdio.h>
void main()
{
char grade[50];
int i,point;
char *b1[9]={"亿","千","百","十","万","千","百","十","元"};
//char *b1[9]={"元","十","百","千","万","十","百","千","亿"};
char *b2[3]={"角","分","厘"};
//do
//{
printf("请输入金额:");
gets(grade);
//for(i=0;i<50;i++)
//{
//if(grade[i]!='.')
//{
//printf("请输入一个带有小数点的金额!\n");
//break;
//}
//}
//}while(grade[i]!='.');
for(i=0;i<50;i++)
{
if(grade[i]=='.')
{
point=i;
break;
}
}
for(i=0;i<50;i++)
{
if(i<point)
{
switch(grade[i])
{
case '0':
printf("零");
break;
case '1':
printf("壹");
break;
case '2':
printf("贰");
break;
case '3':
printf("叁");
break;
case '4':
printf("肆");
break;
case '5':
printf("伍");
break;
case '6':
printf("陆");
break;
case '7':
printf("柒");
break;
case '8':
printf("捌");
break;
case '9':
printf("玖");
break;
}
printf("%s",b1[i+(9-point)]);
}
}
for(i=0;i<50;i++)
{
if(i>point)
{
switch(grade[i])
{
case '0':
printf("零");
break;
case '1':
printf("壹");
break;
case '2':
printf("贰");
break;
case '3':
printf("叁");
break;
case '4':
printf("肆");
break;
case '5':
printf("伍");
break;
case '6':
printf("陆");
break;
case '7':
printf("柒");
break;
case '8':
printf("捌");
break;
case '9':
printf("玖");
break;
}
printf("%s",b2[i]); //数组越界...
}
}
}


 我是指针,却丢失了目标地址!          我是循环,却缺少了结束条件!      我是函数,却没有人来调用!   
2007-04-12 18:36



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




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

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