1 条题解

  • 0
    @ 2025-4-12 21:41:03

    C++ :

    #include<stdio.h>
    #include<cstring>
    using namespace std; 
    int main()
    {
        int p1,p2,p3;
        int i,j,l,n,t;
        char str[1001];
        scanf("%d%d%d",&p1,&p2,&p3);
        scanf("%s",str);
        n=strlen(str);
        printf("%c",str[0]);
        for(i=1;i<n;i++)
        {
                        if(str[i]=='-')
                        {
                                       if(str[i-1]==str[i+1])
                                       {printf("-");continue;}
                                       
                                       if(str[i-1]>=48&&str[i+1]<=57&&str[i+1]>str[i-1])        
                                       {
                                                   if(p1==3)
                                                   {
                                                        for(j=0;j<str[i+1]-str[i-1]-1;j++)
                                                        for(l=0;l<p2;l++)
                                                        printf("*");                                                                                
                                                   }
                                                   if(p1!=3&&p3==1)
                                                   {
                                                        for(t=str[i-1]+1;t<str[i+1];t++)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                           
                                                   }
                                                   if(p1!=3&&p3==2)
                                                   {
                                                        for(t=str[i+1]-1;t>str[i-1];t--)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                                
                                                   }                                                 
                                       }
                                       else if(str[i-1]>=65&&str[i+1]<=90&&str[i+1]>str[i-1])
                                       {
                                                   if(p1==3)
                                                   {
                                                        for(j=0;j<str[i+1]-str[i-1]-1;j++)
                                                        for(l=0;l<p2;l++)
                                                        printf("*");                                                                                    
                                                   }
                                                   if(p1==1&&p3==1)
                                                   {
                                                        for(t=str[i-1]+1+32;t<str[i+1]+32;t++)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                           
                                                   }
                                                   if(p1==1&&p3==2)
                                                   {
                                                        for(t=str[i+1]-1+32;t>str[i-1]+32;t--)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                                
                                                   }
                                                   if(p1==2&&p3==1)
                                                   {
                                                        for(t=str[i-1]+1;t<str[i+1];t++)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                           
                                                   }
                                                   if(p1==2&&p3==2)
                                                   {
                                                        for(t=str[i+1]-1;t>str[i-1];t--)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                                
                                                   }                                    
                                       }
                                       else if(str[i-1]>=97&&str[i+1]<=122&&str[i+1]>str[i-1])
                                       {
                                                   if(p1==3)
                                                   {
                                                        for(j=0;j<str[i+1]-str[i-1]-1;j++)
                                                        for(l=0;l<p2;l++)
                                                        printf("*");                                                                                    
                                                   }
                                                   if(p1==1&&p3==1)
                                                   {
                                                        for(t=str[i-1]+1;t<str[i+1];t++)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                           
                                                   }
                                                   if(p1==1&&p3==2)
                                                   {
                                                        for(t=str[i+1]-1;t>str[i-1];t--)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                                
                                                   }
                                                   if(p1==2&&p3==1)
                                                   {
                                                        for(t=str[i-1]+1-32;t<str[i+1]-32;t++)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                           
                                                   }
                                                   if(p1==2&&p3==2)
                                                   {
                                                        for(t=str[i+1]-1-32;t>str[i-1]-32;t--)                                         
                                                        for(l=0;l<p2;l++)
                                                        printf("%c",t);                                
                                                   }                                    
    
                                       }
                         else printf("-");
                        }
                        else printf("%c",str[i]);
        }
        return 0;    
        }
    
    • 1

    信息

    ID
    1172
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者