币值转换

Posted zcl666

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了币值转换相关的知识,希望对你有一定的参考价值。

1)实验代码

include <stdio.h>

char item[11]="abcdefghij";
char loca[5]="QBSA";
void transport(int num[],int n)
{
int location=0;
while(num[location]==0)
location++;
if(num[location-1]==0&&location!=0)
printf("%c",item[0]);
while(location<=n)
{

    if(num[location]!=0&&location<=n)
    {

        if(location!=n)
        printf("%c%c",item[num[location]],loca[4-n-1+location]);
        else
            printf("%c",item[num[location]]);


    }
    else if(num[location]==0&&num[location+1]!=0&&location<=n-1)
        printf("%c",item[0]);
    location++;


}
return;

}
int main()
{
char p[10];

char ch;
int num[9];
int i=0;
while((ch=getchar())!=‘
‘)
{
    p[i]=ch;
    i++;

}
p[i]=‘‘;
int length=strlen(p);
for(i=0;i<=length-1;i++)
    num[i]=p[i]-‘0‘;
if(length<=4)
   transport(num,length-1);
else if(length<=8)
{
    transport(num,length-5);
    printf("W");
    transport(num+length-4,3);
}
else
{
    printf("%cY",item[num[0]]);
    transport(num+1,3);
    if(num[1]!=0||num[2]!=0||num[3]!=0||num[4]!=0)
        printf("W");
    if(num[length-4]==0)
       printf("%c",item[0]);
    transport(num+5,3);

}

return 0;

}
这个是网上搜的















以上是关于币值转换的主要内容,如果未能解决你的问题,请参考以下文章

币值转换

币值转换

币值转换

币值转换

币值转换

币值转换