币值转换

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())!='\n')
{
    p[i]=ch;
    i++;

}
p[i]='\0';
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;

}
这个是网上搜的

posted @ 2019-02-20 21:12  周成龙  阅读(126)  评论(0编辑  收藏  举报