码迷,mamicode.com
首页 > 其他好文 > 详细

币值转换

时间:2019-02-20 21:26:40      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:i++   void   [1]   char   clu   getchar   pre   n+1   transport   

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;

}
这个是网上搜的

币值转换

标签:i++   void   [1]   char   clu   getchar   pre   n+1   transport   

原文地址:https://www.cnblogs.com/zcl666/p/10409262.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!