zjPan


私信TA

用户名:18014852317

访问量:925

签 名:

等  级
排  名 5394
经  验 1485
参赛次数 0
文章发表 3
年  龄 0
在职情况 学生
学  校 常州工学院
专  业

  自我简介:

解题思路:分类

注意事项:[1,9]    [10,26]     (26,oo)

参考代码:

#include<stdio.h>

int main()

{

    char s[200010];

    gets(s);

    int i = 0;

    while(s[i]){

        int t = 0;

        if(s[i+1]){

            t = (s[i]-'0')*10+s[i+1]-'0';

        }

        else

            t = s[i]-'0';

            

            

        if(t >= 1 && t <= 9){

            printf("%c",t+'A'-1);

            i = i+1;

        }

        else if(t > 26){

            printf("%c",s[i]+16);

            i = i+1;

        }

        else{

            if(t == 10){

                printf("%c",t+'A'-1);

            }else if (s[i+2] == '0' &&(t == 11||t==12||t==21||t==22)){

                printf("%c",t/10+'A'-1);

                i = i+1;

                

            }else{

                printf("%c",t+'A'-1);

                i = i+2;

            }

        }

    }

}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

当t的值为10的时候,i为什么不变,这样不会导致死循环吗
2024-04-08 00:01:21
#include<stdio.h>

int main()

{

    char s[200010];

    gets(s);

    int i = 0;

    while(s[i]){

        int t = 0;

        if(s[i+1]){

            t = (s[i]-'0')*10+s[i+1]-'0';

        }

        else

            t = s[i]-'0';

            

            

        if(t >= 1 && t <= 9){

            printf("%c",t+'A'-1);

            i = i+1;

        }

        else if(t > 26){

            printf("%c",s[i]+16);

            i = i+1;

        }

        else{

                printf("%c",t+'A'-1);

                i = i+2;

            

        }

    }

}
2024-02-07 14:48:27
  • «
  • 1
  • »