人民币大小写转换程序运行不出来,大哥,大姐,来看一下
struct num{
char money[20];
int len;
};
void substring (struct num *sub,struct num *s,int pos,int len) /*********求子串**********/
{
int i;
s->money[0]='\0';
s->len=0;
if ( pos<1 || pos>sub->len || len<0 || len>sub->len-pos+1)
printf("\n输入错误\n");
for(i=0;i<len;i++)
s->money[i]=sub->money[pos+i-1];
s->money[i]='\0';
s->len=i;
}
int Index(struct num *S, struct num *T, int pos) /*******20****子串定位***********/
{
int i=pos-1, j=0;
while(i<=S->len&&j<=T->len)
{
if (S->money[i] == T->money[j])
{
++i;
++j;
}
else
{
i = i-j+1;
j = 0;
}
}
if (j > T->len)
return i-T->len+1;
else printf("\n没有找到\n");
}
void reverse(struct num *ch) /*******39*****串倒置**************/
{
int len;
int i;
char middle;
for(i=0; i<ch->len/2; i++)
{
middle=ch->money[i];
ch->money[i] = ch->money[ch->len-i-1];
ch->money[ch->len-i-1]=middle;
}
ch->money[ch->len] = '\0'; /********51*********/
}
void numbertrans(char ch)
{
switch(ch)
{
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;
default:printf("你输如的钱数有误!");
}
}
void trans1(int i) /**************70*************/
{
if(i==1)printf("万");
else if(i==2)printf("亿");
else ;
}
void trans0(int len,int i)
{
if(len==4)
if(i==0) printf("千");
else if(i==1) printf("百"); /**************80*************/
else if(i==2) printf("拾");
else ;
if(len==3)
if(i==0) printf("百");
else if(i==1) printf("拾");
else ;
if(len==2)
if(i==0) printf("拾");
else ;
}
void trans(struct num ch)
{
int i;
for(i=0;i<ch.len;i++)
{
numbertrans(ch.money[i]);
trans0(ch.len,i);
}
}
main() /***********100******主函数**************/
{
int i,s=1,j=4,k,begin,length,post,start=0;
struct num *p;
struct num yourmoney,dot,substring1,substring2,substring3;
substring1.money[0]='\0';
substring1.len=0;
substring2.money[0]='\0';
substring2.len=0;
substring3.money[0]='\0';
substring3.len=0; /*110*/
struct num substring[3];
for(i=0;i<3;i++)
{
substring[i].money[0]='\0';
substring[i].len=0;
}
dot.money[0]='.'; /**********117***********/
dot.money[1]='\0';
dot.len=1;
yourmoney.money[0]='\0';
yourmoney.len=0;
printf("请你输入你的钱数:\n");
printf("输入你的钱数以后按回车键!\n");
for(i=0;i<20;i++)
{
scanf("%c",&yourmoney.money[i]);
}
yourmoney.money[i]='\0';
yourmoney.len=i;
post=Index(&yourmoney,&dot,start);
begin=start;
length=post+1;
substring[i].money[0]='\0';
substring[i].len=0;
substring(&yourmoney,
&substring1,begin,length); /*****求整钱数*125*****/
begin=post+2;
length=start+2;
substring(&yourmoney,
&substring2,begin,length);/*****求零钱数*******/
reverse(&substring1);
k=substring1.len/j;
if(substring1.len%j)
{
begin=k*j;
length=substring1.len-k*j;
substring(&substring1,&substring3,begin,length);/**********135*********/
reverse(&substring3);
}
for(i=0,s=1;i<k;i++)
{
if(i==0)
{
p=substring+i;
begin=s;
length=j;
substring(&substring1,p,begin,length);
}
else
{
p=substring+i;
begin=i*j+1;
length=j;
substring(&substring1,p,begin,length);
}
reverse(p);
}
trans(substring3);
trans1(k);
for(i=k-1;i>=0;i--)
{
trans(substring[i]);
trans1(i);
}
}
这个程序我运行不出来,请高手帮我运行一下,看是什么原因?谢谢个为浏览者!!!!!!!!!!