解题思路:





注意事项:





参考代码:

不写为啥了:


#include<cstdio>
#include<cstring>
using namespace std;
char a[200];
bool first=true;
int main(){    
int p1,p2,p3,l,i=0,j=0;    
char k;    
scanf("%d%d%d\n",&p1,&p2,&p3);
    gets(a);
    l=strlen(a);
    first=true;    
    for(i=0;i<l;i++)
    {        if(first&&a[i]=='-')//判断开头的“-”
        {    
            printf("-");     
        }        else if(i==l-1&&a[i]=='-')//判断末尾的“-”
        {            printf("-");
        }        else if(a[i]!='-')//不为减号要记得输出
        {            printf("%c",a[i]);
            first=false;//别忘记置标记
        }        else
        {            if(a[i-1]>=a[i+1]||(a[i-1]-'a'<0&&a[i+1]-'a'>=0)||(a[i-1]-'a'>=0&&a[i+1]-'a'<0))//判断是否有“3-1”“数字-字母”“字母-数字”“大的字母-小的字母”情况
            {                printf("-");
            }            else if(a[i-1]+1!=a[i+1])
            {                if(p1==1)
                {                    if(p3==2)//倒序
                    {                        if(a[i+1]<='9'&&a[i+1]>='0')//前后为数字
                        {                            for(k=a[i-1]+1;k<a[i+1];k++)
                            {                                for(j=0;j<p2;j++)
                                {                                    printf("%c",k);
                                }
                            }
                        }                        else//前后为字母
                        {                            for(k=a[i+1]-1;k>a[i-1];k--)
                            {                                for(j=0;j<p2;j++)//注意个数
                                {                                    printf("%c",k);
                                }    
                            }
                        }
                    }                    else//正序输出
                    {                        for(k=a[i-1]+1;k<a[i+1];k++)
                        {                            for(j=0;j<p2;j++)
                            {                                printf("%c",k);
                            }
                        }
                    }
                }                if(p1==2)    
                {                    if(p3==2)
                    {                        if(a[i+1]<='9'&&a[i+1]>='0')
                        {                            for(k=a[i+1]-1;k>=a[i-1]+1;k--)
                            {                                for(j=0;j<p2;j++)
                                {                                    printf("%c",k);
                                }
                            }
                        }                        else
                        {                            for(k=a[i+1]-'a'+'A'-1;k>a[i-1]-'a'+'A';k--)//改成大写字母
                            {                                for(j=0;j<p2;j++)
                                {                                    printf("%c",k);
                                }
                            }
                        }
                    }                    else
                    {                        for(k=a[i-1]-'a'+'A'+1;k<a[i+1]-'a'+'A';k++)
                        {                            for(j=0;j<p2;j++)
                            {                                printf("%c",k);
                            }
                        }
                    }
                }                if(p1==3)//输出星号
                {                    for(k=a[i-1]+1;k<a[i+1];k++)
                    {                        for(j=0;j<p2;j++)
                        {                            printf("*");
                        }
                    }
                }
            }
        }
    }    return 0;
}


点赞(1)
 

0.0分

2 人评分

C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:

一点编程也不会写的:零基础C语言学练课程

解决困扰你多年的C语言疑难杂症特性的C语言进阶课程

从零到写出一个爬虫的Python编程课程

只会语法写不出代码?手把手带你写100个编程真题的编程百练课程

信息学奥赛或C++选手的 必学C++课程

蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程

手把手讲解近五年真题的蓝桥杯辅导课程

评论列表 共有 0 条评论

暂无评论