159 条题解

  • 1
    @ 2021-09-04 14:17:18
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int p1,p2,p3,i=0,k;
        char ch[300],be,af,f,j,p; 
        scanf("%d%d%d%s",&p1,&p2,&p3,ch);
        while(ch[i]){
            be=ch[i-1];
            af=ch[i+1];
            f=ch[i];
            if(f=='-'&&af>be&&(be>='0'&&af<='9'||be>='a'&&af<='z')){
                for(p3==1?j=be+1:j=af-1; p3==1?j<af:j>be; p3==1?j++:j--){
                    p=j;
                    if(p1==2) 
                        p=(p>='a')?p-32:p;
                    else if(p1==3)
                        p='*';
                    for(k=0; k<p2; k++)
                        printf("%c",p);
                }
            } 
            else
                printf("%c",f);
            i++;
        }
        return 0;
    }
    
  • 1
    @ 2017-10-21 13:37:15

    var s,x:ansistring;
    p1,p2,p3,i,j,k:longint;
    begin
    readln(p1,p2,p3);
    read(s);
    x:='';
    for i:=1 to length(s) do
    if s[i]='-' then begin
    if ((s[i-1]>='a')and(s[i+1]<='z'))or((s[i-1]>='0')and(s[i+1]<='9')) then
    begin
    if ord(s[i+1])<=ord(s[i-1]) then x:=x+s[i];
    if ord(s[i+1])-1>ord(s[i-1]) then begin
    if p1=1 then
    if p3=1 then begin
    for k:=ord(lowercase(s[i-1]))+1 to ord(lowercase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end
    else begin
    for k:=ord(lowercase(s[i+1]))-1 downto ord(lowercase(s[i-1]))+1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end;
    if p1=2 then
    if p3=1 then begin
    for k:=ord(upcase(s[i-1]))+1 to ord(upcase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end
    else begin
    for k:=ord(upcase(s[i+1]))-1 downto ord(upcase(s[i-1]))+1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end;
    if p1=3 then
    for k:=ord(upcase(s[i-1]))+1 to ord(upcase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+'*';
    end;
    end
    else x:=x+s[i];
    end
    else x:=x+s[i];
    write(x);
    end.

  • 1
    @ 2017-05-15 11:19:27

    http://blog.csdn.net/xljer_/article/details/72123653
    见博客

    思路
    模拟 进行字符串操作
    将操作过程写成函数 进行输出 一定要注意细节 考虑特殊情况
    如’-‘开头,’—’连在一起,还有当p1=2时数字不能和小写字母一样处理
    代码如下
    c++
    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<algorithm>
    #include<cmath>
    #include<cstring>
    #define N 1000005
    using namespace std;
    char a[N];
    int p1,p2,p3;
    void deal(char x,char y){
    if(x==y-1)
    return;//如果没有展开 就直接return 因为已经输出过x和y
    char temp[500];
    int p=0;
    for(int i=x+1;i<=y-1;i++){
    for(int j=1;j<=p2;j++){
    if(p1==1) temp[++p]=i;
    else if(p1==2&&i>='a'&&i<='z')//p1=2的字母情况
    temp[++p]=i-'a'+'A';
    else if(p1==2&&i>='1'&&i<='9')//p1=2的数字情况
    temp[++p]=i;
    else if(p1==3)
    temp[++p]='*';
    }
    }
    if(p3==1)//逆序输出情况
    for(int i=1;i<=p;i++)
    cout<<temp[i];
    else if(p3==2)
    for(int i=p;i>=1;i--)
    cout<<temp[i];
    }
    int main(){
    scanf("%d%d%d",&p1,&p2,&p3);
    scanf("%s",a+1);
    int len=strlen(a+1);
    for(int i=1;i<=len;i++){
    if(a[i]=='-'){
    char x=a[i-1];
    char y=a[i+1];
    if(x>='a'&&x<='z'&&y<='z'&&y>='a'&&x<y||x>='0'&&x<='9'&&y>='0'&&y<='9'&&x<y){//满足条件 不输出'-' 输出两个字符的展开
    deal(x,y);
    //cout<<" "<<"deal"<<" ";
    }
    else cout<<a[i];//不满足 如s-4就输出'-'
    }
    else
    cout<<a[i];
    }
    }

  • 0
    @ 2020-04-14 10:39:49

    一道细心点就能做对的模拟题。

    下面分析下坑点和分层思路:

    坑点:

    1、"-"可能出现在第一个或最后一个,同时可能连续出现,用判断特殊处理

    2、如果x-y中x为数字而y为字母,应选择不展开!(与题目中提及的特殊情况不重叠)

    分层:

    1、是符号还是"-",同时加上对"-"的特殊处理

    2、x与y的关系,分<=、>、x+1=y

    3、x与y同时字母还是数字

    4、以p1、p3、p2的层次循环即可

    附上代码
    cpp
    #include <bits/stdc++.h>
    using namespace std;
    int p1,p2,p3;
    vector<char> ans;
    string s;
    int main()
    {
    cin >> p1 >> p2 >> p3 >> s;
    for(int i=0;i<s.size();i++)
    {
    if(s[i]!='-') ans.push_back(s[i]);
    else if((i==0 || i==s.size()-1) && s[i]=='-' ) ans.push_back('-');
    else if(s[i]=='-' && (s[i-1]=='-' || s[i+1]=='-')) ans.push_back('-');
    else if(s[i]=='-')
    {
    if(s[i-1]>=s[i+1] || (s[i-1]<58 && s[i+1]>96)) ans.push_back('-');
    else if(s[i+1]==s[i-1]+1) continue;
    else
    {
    if(p1==3)
    {
    for(int k=1;k<=(s[i+1]-s[i-1]-1)*p2;k++) ans.push_back('*');
    }
    else if(s[i+1]<=57 && s[i+1]>=48 && s[i-1]<=57 && s[i-1]>=48)
    {
    if(p3==1)
    {
    for(int k=s[i-1]+1;k<=s[i+1]-1;k++)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k));
    }
    else if(p3==2)
    {
    for(int k=s[i+1]-1;k>=s[i-1]+1;k--)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k));
    }
    }
    else if(s[i+1]<=122 && s[i+1]>=97 && s[i-1]<=122 && s[i-1]>=97)
    {
    if(p1==1)
    {
    if(p3==1)
    {
    for(int k=s[i-1]+1;k<=s[i+1]-1;k++)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k));
    }
    else if(p3==2)
    {
    for(int k=s[i+1]-1;k>=s[i-1]+1;k--)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k));
    }
    }
    else if(p1==2)
    {
    if(p3==1)
    {
    for(int k=s[i-1]+1;k<=s[i+1]-1;k++)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k-32));
    }
    else if(p3==2)
    {
    for(int k=s[i+1]-1;k>=s[i-1]+1;k--)
    for(int j=1;j<=p2;j++)
    ans.push_back(char(k-32));
    }
    }
    }
    }
    }
    }
    for(int i=0;i<ans.size();i++) cout << ans[i];
    return 0;
    }

  • 0
    @ 2018-03-30 08:10:01

    #include <stdio.h>
    #include <string.h>
    int p1,p2,p3,len;
    char a[100000];
    char f( int i)
    {
    int j;
    char c;
    if(i==0||i==len-1)
    {
    printf("-");
    return 0;
    }
    if(a[i+1]=='-'||a[i-1]=='-')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]>='a'&&a[i+1]<='z')
    if(a[i-1]>='0'&&a[i-1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i-1]>='a'&&a[i-1]<='z')
    if(a[i+1]>='0'&&a[i+1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]-a[i-1]==1)
    return 0;
    if(a[i+1]-a[i-1]<=0)
    {
    printf("-");
    return 0;
    }
    if(p3==1)
    {
    if(p1==1)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')

    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    if(p3==2)
    {
    if(p1==1)
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    return 0;
    }
    int main()
    {
    scanf("%d %d %d",&p1,&p2,&p3);
    scanf("%s",a);
    len=strlen(a);
    int i=0;
    while(i<len)
    {
    if(a[i]!='-')
    printf("%c",a[i]);
    else
    f(i);
    i++;
    }
    }

  • 0
    @ 2018-03-30 08:09:24

    #include <stdio.h>
    #include <string.h>
    int p1,p2,p3,len;
    char a[100000];
    char f( int i)
    {
    int j;
    char c;
    if(i==0||i==len-1)
    {
    printf("-");
    return 0;
    }
    if(a[i+1]=='-'||a[i-1]=='-')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]>='a'&&a[i+1]<='z')
    if(a[i-1]>='0'&&a[i-1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i-1]>='a'&&a[i-1]<='z')
    if(a[i+1]>='0'&&a[i+1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]-a[i-1]==1)
    return 0;
    if(a[i+1]-a[i-1]<=0)
    {
    printf("-");
    return 0;
    }
    if(p3==1)
    {
    if(p1==1)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')

    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    if(p3==2)
    {
    if(p1==1)
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    return 0;
    }
    int main()
    {
    scanf("%d %d %d",&p1,&p2,&p3);
    scanf("%s",a);
    len=strlen(a);
    int i=0;
    while(i<len)
    {
    if(a[i]!='-')
    printf("%c",a[i]);
    else
    f(i);
    i++;
    }
    }

  • 0
    @ 2018-03-30 08:08:21

    #include <stdio.h>
    #include <string.h>
    int p1,p2,p3,len;
    char a[100000];
    char f( int i)
    {
    int j;
    char c;
    if(i==0||i==len-1)
    {
    printf("-");
    return 0;
    }
    if(a[i+1]=='-'||a[i-1]=='-')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]>='a'&&a[i+1]<='z')
    if(a[i-1]>='0'&&a[i-1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i-1]>='a'&&a[i-1]<='z')
    if(a[i+1]>='0'&&a[i+1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]-a[i-1]==1)
    return 0;
    if(a[i+1]-a[i-1]<=0)
    {
    printf("-");
    return 0;
    }
    if(p3==1)
    {
    if(p1==1)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')

    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    if(p3==2)
    {
    if(p1==1)
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    return 0;
    }
    int main()
    {
    scanf("%d %d %d",&p1,&p2,&p3);
    scanf("%s",a);
    len=strlen(a);
    int i=0;
    while(i<len)
    {
    if(a[i]!='-')
    printf("%c",a[i]);
    else
    f(i);
    i++;
    }
    }

  • 0
    @ 2018-03-30 08:08:02

    #include <stdio.h>
    #include <string.h>
    int p1,p2,p3,len;
    char a[100000];
    char f( int i)
    {
    int j;
    char c;
    if(i==0||i==len-1)
    {
    printf("-");
    return 0;
    }
    if(a[i+1]=='-'||a[i-1]=='-')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]>='a'&&a[i+1]<='z')
    if(a[i-1]>='0'&&a[i-1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i-1]>='a'&&a[i-1]<='z')
    if(a[i+1]>='0'&&a[i+1]<='9')
    {
    printf("-");
    return 0;
    }
    if(a[i+1]-a[i-1]==1)
    return 0;
    if(a[i+1]-a[i-1]<=0)
    {
    printf("-");
    return 0;
    }
    if(p3==1)
    {
    if(p1==1)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')

    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    if(p3==2)
    {
    if(p1==1)
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c);
    if(p1==2)
    {
    if(a[i-1]>='a'&&a[i-1]<='z')
    for(c=a[i+1]-1;c>a[i-1];c--)
    for(j=0;j<p2;j++)
    printf("%c",c+'A'-'a');
    else
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",c);
    }
    if(p1==3)
    for(c=a[i-1]+1;c<a[i+1];c++)
    for(j=0;j<p2;j++)
    printf("%c",'*');
    }
    return 0;
    }
    int main()
    {
    scanf("%d %d %d",&p1,&p2,&p3);
    scanf("%s",a);
    len=strlen(a);
    int i=0;
    while(i<len)
    {
    if(a[i]!='-')
    printf("%c",a[i]);
    else
    f(i);
    i++;
    }
    }

  • 0
    @ 2017-11-26 12:25:07

    丢人丢到家了
    连续6次才过
    分别30/40/60/0/90/100分
    差点砸电脑←_←
    犯的都是智障一般但是看样例看不出来的错
    拿到了数据才解决了最后两个bug←_←

    贴代码,挂自己orz

    //行末注释的都是出错的点orz
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #include <cstring>
    using namespace std;
    
    int p1,p2,p3,i,tx,ty,tz,d1=1,d2=1;
    char in[100010]={0},out[100010]={0},t[1010];
    int main()
    {
        cin>>p1>>p2>>p3;
        cin>>in;
        if(p1==1) p1=0;
        else if(p1==2) p1=-32;//
        else p1=-1000;
        out[0]=in[0];
        while(in[d1]!=0)
        { 
            if(in[d1]!='-')
            {
                out[d2]=in[d1];
                d2++;
            }
            else
            {
                if(in[d1-1]>='0' && in[d1+1]<='9' || in[d1-1]>='a' && in[d1+1]<='z')
                {//
                    if(in[d1-1]+1<=in[d1+1])
                    {
                        tx=1;ty=in[d1-1]+1;
                        while(ty<in[d1+1])
                        {
                            for(i=1;i<=p2;i++)
                            {
                                tz=ty+p1;
                                if(tz>=16&&tz<=25) tz+=32;//
                                if(tz<0) t[tx]='*';//
                                else t[tx]=tz;
                                tx++;
                            }
                            ty++;
                        }
                        if(tx!=1)
                        {
                            if(p3==1) for(i=1;i<=tx-1;i++)
                            {
                                out[d2]=t[i];
                                d2++;
                            }
                            else for(i=tx-1;i>=1;i--)
                            {//
                                out[d2]=t[i];
                                d2++;
                            }
                        }
                    }
                    else
                    {
                        out[d2]='-';
                        d2++;
                    }
                }
            else
            {
                out[d2]='-';
                d2++;
            }
            }
            d1++;
        }
        d2=0;
        while(out[d2]!=0) {cout<<out[d2];d2++;}
        return 0;
    }
    
  • 0
    @ 2017-11-16 20:08:57

    哈哈,写了半年

    #include<iostream>
    #include<cctype>
    #define FOR(i,x,y) for(i=x;i<=y;++i)
    using namespace std;
    int main()
    {
        string s;
        int p1,t,p2,p3;
        cin>>p1>>p2>>p3;
        cin>>s;
        int i,j;
        char c;
        if(p1==1)
        {
            if(p3==1)
            {
                for(i=0;i<s.length();++i)
                    if(s[i]=='-')
                {
                    if(s[i+1]-s[i-1]==1)
                    {
    
                    }
                    else if(s[i-1]>=s[i+1])
                    {
                        cout<<"-";
                    }
                    else if(isalpha(s[i-1])&&isalpha(s[i+1]))
                    {
                        for(c = tolower(s[i-1]+1);c<tolower(s[i+1]);++c)
                        {
                            for(j=0;j<p2;++j)
                                cout<<c;
                        }
                    }
                    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
                    {
                        for(t = s[i-1]-'0'+1;t<s[i+1]-'0';++t)
                        {
                          for(j=0;j<p2;++j)
                                cout<<t;
                        }
                    }
                    else
                        cout<<s[i];
                }
                else
                    cout<<s[i];
            }
            else if(p3==2)
            {
                for(i=0;i<s.length();++i)
                    if(s[i]=='-')
                {
                    if(s[i+1]-s[i-1]==1)
                    {
    
                    }
                    else if(s[i-1]>=s[i+1])
                    {
                        cout<<"-";
                    }
                    else if(isalpha(s[i-1])&&isalpha(s[i+1]))
                    {
                        for(c = tolower(s[i+1])-1;c>=tolower(s[i-1]+1);--c)
                        {
                            for(j=0;j<p2;++j)
                                cout<<c;
                        }
                    }
                    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
                    {
                        for(t = s[i+1]-'0'-1;t>=s[i-1]-'0'+1;--t)
                        {
                          for(j=0;j<p2;++j)
                                cout<<t;
                        }
                    }
                    else
                        cout<<s[i];
            }
            else
                cout<<s[i];
        }
        }
        else if(p1==2)
        {
            if(p3==1)
            {
                for(i=0;i<s.length();++i)
                    if(s[i]=='-')
                {
                    if(s[i+1]-s[i-1]==1)
                    {
    
                    }
                    else if(s[i-1]>=s[i+1])
                    {
                        cout<<"-";
                    }
                    else if(isalpha(s[i-1])&&isalpha(s[i+1]))
                    {
                        for(c = toupper(s[i-1]+1);c<toupper(s[i+1]);++c)
                        {
                            for(j=0;j<p2;++j)
                                cout<<c;
                        }
                    }
                    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
                    {
                        for(t = s[i-1]-'0'+1;t<s[i+1]-'0';++t)
                        {
                          for(j=0;j<p2;++j)
                                cout<<t;
                        }
                    }
                    else
                        cout<<s[i];
                }
                else
                    cout<<s[i];
            }
            else if(p3==2)
            {
                for(i=0;i<s.length();++i)
                    if(s[i]=='-')
                {
                    if(s[i+1]-s[i-1]==1)
                    {
    
                    }
                    else if(s[i-1]>=s[i+1])
                    {
                        cout<<"-";
                    }
                    else if(isalpha(s[i-1])&&isalpha(s[i+1]))
                    {
                        for(c = toupper(s[i+1]-1);c>=toupper(s[i-1]+1);--c)
                        {
                            for(j=0;j<p2;++j)
                                cout<<c;
                        }
                    }
                    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
                    {
                        for(t = s[i+1]-'0'-1;t>=s[i-1]-'0'+1;--t)
                        {
                          for(j=0;j<p2;++j)
                                cout<<t;
                        }
                    }
                    else
                        cout<<s[i];
            }
            else
                cout<<s[i];
            }
        }
        else if(p1==3)
        {
            for(i=0;i<s.length();++i)
                    if(s[i]=='-')
                    {
                    if(s[i+1]-s[i-1]==1)
                    {
    
                    }
                    else if(s[i-1]>=s[i+1])
                    {
                        cout<<"-";
                    }
                     else if(isalpha(s[i-1])&&isalpha(s[i+1]))
                    {
                        for(c = toupper(s[i+1]-1);c>=toupper(s[i-1]+1);--c)
                        {
                            for(j=0;j<p2;++j)
                                cout<<"*";
                        }
                    }
                    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
                    {
                        for(t = s[i+1]-'0'-1;t>=s[i-1]-'0'+1;--t)
                        {
                          for(j=0;j<p2;++j)
                                cout<<"*";
                        }
                    }
                    else
                        cout<<s[i];
                    }
                    else
                        cout<<s[i];
        }
    
    }
    
    
  • 0
    @ 2017-11-16 19:52:54

    wa,不知道为啥
    ```cpp
    #include<iostream>
    #include<cctype>
    #define FOR(i,x,y) for(i=x;i<=y;++i)
    using namespace std;
    int main()
    {
    string s;
    int p1,t,p2,p3;
    cin>>p1>>p2>>p3;
    cin>>s;
    int i,j;
    char c;
    if(p1==1)
    {
    if(p3==1)
    {
    for(i=0;i<s.length();++i)
    if(s[i]=='-')
    {
    if(isalpha(s[i-1])&&isalpha(s[i+1]))
    {
    for(c = tolower(s[i-1]+1);c<tolower(s[i+1]);++c)
    {
    for(j=0;j<p2;++j)
    cout<<c;
    }
    }
    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
    {
    for(t = s[i-1]-'0'+1;t<s[i+1]-'0';++t)
    {
    for(j=0;j<p2;++j)
    cout<<t;
    }
    }
    else
    cout<<s[i];
    }
    else
    cout<<s[i];
    }
    else if(p3==2)
    {
    for(i=0;i<s.length();++i)
    if(s[i]=='-')
    {
    if(isalpha(s[i-1])&&isalpha(s[i+1]))
    {
    for(c = tolower(s[i+1])-1;c>=tolower(s[i-1]+1);--c)
    {
    for(j=0;j<p2;++j)
    cout<<c;
    }
    }
    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
    {
    for(t = s[i+1]-'0'-1;t>=s[i-1]-'0'+1;--t)
    {
    for(j=0;j<p2;++j)
    cout<<t;
    }
    }
    else
    cout<<s[i];
    }
    else
    cout<<s[i];
    }
    }
    else if(p1==2)
    {
    if(p3==1)
    {
    for(i=0;i<s.length();++i)
    if(s[i]=='-')
    {
    if(isalpha(s[i-1])&&isalpha(s[i+1]))
    {
    for(c = toupper(s[i-1]+1);c<toupper(s[i+1]);++c)
    {
    for(j=0;j<p2;++j)
    cout<<c;
    }
    }
    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
    {
    for(t = s[i-1]-'0'+1;t<s[i+1]-'0';++t)
    {
    for(j=0;j<p2;++j)
    cout<<t;
    }
    }
    else
    cout<<s[i];
    }
    else
    cout<<s[i];
    }
    else if(p3==2)
    {
    for(i=0;i<s.length();++i)
    if(s[i]=='-')
    {
    if(isalpha(s[i-1])&&isalpha(s[i+1]))
    {
    for(c = toupper(s[i+1]-1);c>=toupper(s[i-1]+1);--c)
    {
    for(j=0;j<p2;++j)
    cout<<c;
    }
    }
    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
    {
    for(t = s[i+1]-'0'-1;t>=s[i-1]-'0'+1;--t)
    {
    for(j=0;j<p2;++j)
    cout<<t;
    }
    }
    else
    cout<<s[i];
    }
    else
    cout<<s[i];
    }
    }
    else if(p1==3)
    {
    for(i=0;i<s.length();++i)
    if(s[i]=='-')
    {
    if(isalpha(s[i-1])&&isalpha(s[i+1]))
    {
    for(c = toupper(s[i+1]-1);c>=toupper(s[i-1]+1);--c)
    {
    for(j=0;j<p2;++j)
    cout<<"*";
    }
    }
    else if(isdigit(s[i-1])&&isdigit(s[i+1]))
    {
    for(t = s[i+1]-1;t>=s[i-1]+1;--t)
    {
    for(j=0;j<p2;++j)
    cout<<"*";
    }
    }
    else
    cout<<s[i];
    }
    else
    cout<<s[i];
    }
    else
    cout<<s;

    }

  • 0
    @ 2017-09-14 18:51:06
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <sstream>
    #include <iomanip>
    using namespace std;
    
    int p1,p2,p3;
    char s[10000+1];
    #define s(x) s[x-1]
    
    inline int check_a_1(char c)
    {
        if ('A'<=c&&c<='Z')
            return 1;
        else if ('a'<=c&&c<='z')
            return 1;
        else
            return 0;
    }
    
    inline int check_d_1(char c)
    {
        if ('0'<=c&&c<='9')
            return 1;
        else
            return 0;
    }
    
    inline char p_p1_1(char c)
    {
        if (p1==1&&'A'<=c&&c<='Z')
            return c-'A'+'a';
        else if (p1==2&&'a'<=c&&c<='z')
            return c-'a'+'A';
        else if (p1==3)
            return '*';
        else
            return c;
    }
    
    int main()
    {
        while (~scanf("%d%d%d",&p1,&p2,&p3))
        {
            memset(s,0,sizeof(s));
            scanf("%s",&(s(1)));
            for (int i=1,sl=strlen(s);i<=sl;i++)
                if (s(i)=='-')
                {
                    char c1='$',c2='$';
                    if (1<i&&i<sl)
                        c1=s(i-1),c2=s(i+1);
                    if (c1==c2-1)
                        ;
                    else if (c1>=c2||c1=='$'||c2=='$'||check_a_1(c1)==check_d_1(c1)||check_a_1(c2)==check_d_1(c2)||(check_a_1(c1)!=check_a_1(c2)&&check_d_1(c1)!=check_d_1(c2)))
                        printf("%c",s(i));
                    else if (p3==1)
                    {
                        for (char j=c1+1;j<=c2-1;j++)
                            for (int k=1;k<=p2;k++)
                                printf("%c",p_p1_1(j));
                    }
                    else if (p3==2)
                    {
                        for (char j=c2-1;j>=c1+1;j--)
                            for (int k=1;k<=p2;k++)
                                printf("%c",p_p1_1(j));
                    }
                }
                else
                    printf("%c",s(i));
            printf("\n");
        }
    }
    
  • 0
    @ 2016-11-18 00:02:59

    各种细节性错误导致狂WA。。OrzOrzOrz
    #include <iostream>
    #include <algorithm>
    #include <cstdlib>
    #include <cstdio>
    #include <vector>
    #include <queue>
    #include <cstring>
    #include <cassert>
    #include <cctype>

    using namespace std;

    #define T { \
    for(int k=0;k<p2;k++){ \
    if(p1==3)putchar('*');\
    else{\
    if(isdigit(j))putchar(j);\
    else putchar(p1==1?tolower(j):toupper(j));\
    }\
    }\
    }

    int p1,p2,p3;
    string str;
    int main(){
    cin>>p1>>p2>>p3>>str;
    for(int i=0;str[i];i++){
    if(str[i]=='-'){
    if(str[i-1]<str[i+1]&&((isdigit(str[i-1])&&isdigit(str[i+1]))||(isalpha(str[i-1])&&isalpha(str[i+1])))){
    if(p3==1){
    for(int j=str[i-1]+1;j<=str[i+1]-1;j++)T;
    }else{
    for(int j=str[i+1]-1;j>=str[i-1]+1;j--)T;
    }
    }else putchar('-');
    }else putchar(str[i]);
    }
    }

  • 0
    @ 2016-09-19 21:30:37

    代码长度==代码行数?
    c++
    #include<bits/stdc++.h>
    using namespace std;
    #define T for (int j=1;j<=p2;j++) if (p1==1) cout<<c;else if(p1==2) cout<<(char)toupper(c);else cout<<'*'
    #define a isalpha
    #define d isdigit
    string s;
    int p1,p2,p3;
    int main(){
    cin>>p1>>p2>>p3>>s;
    for (int i=0;i<s.length()-1;i++){
    if (s[i]!='-') cout<<s[i];
    else if (s[i-1]<s[i+1]&&(d(s[i-1])&&d(s[i+1])||a(s[i-1])&&a(s[i+1])))
    if (p3==1)for (char c=s[i-1]+1;c<s[i+1];c++)T;
    else for (char c=s[i+1]-1;c>s[i-1];c--)T;
    else cout<<'-';
    }
    cout<<s[s.length()-1];
    return 0;
    }

    仅由于数据水才过的

  • 0
    @ 2016-07-19 23:58:49

    坑,交了4遍才过。注意 -- 还有 数字-字母 的情况

  • 0
    @ 2016-07-14 17:27:26
    #include<iostream>
    #include<cstdio>
    #include<cctype>
    #include<string>
    using namespace std;
    
    int p1, p2, p3;
    string s;
    
    void print (char c) {
        for (int i = 0; i < p2; i++) cout << c;
    }
    
    void print (char c1, char c2) {
        if (p3 == 1) for (char c = c1+1; c < c2; c++) print(c);
        if (p3 == 2) for (char c = c2-1; c > c1; c--) print(c);
    }
    
    void print (int x) {
        for (int i = 0; i < x; i++) print('*');
    }
    
    void extend (int p) {
        if (!p || p >= s.length()-1) { cout << '-'; return;}
        char c1 = s[p-1], c2 = s[p+1];
        bool alpha = (isalpha(c1) && isalpha(c2));
        bool digit = (isdigit(c1) && isdigit(c2));
        
        if (!alpha && !digit) { cout << '-'; return;}
        if (c1 >= c2) { cout << '-'; return;}
        
        if (alpha) {
            if (p1 == 1) print (c1, c2);
            else if (p1 == 2) print (c1+'A'-'a' , c2+'A'-'a');
            else if (p1 == 3) print (c2-c1-1);
        }
        else {
            if (p1 == 1 || p1 == 2) print (c1, c2);
            else if (p1 == 3) print (c2-c1-1);
        }
    }
    
    int main ()
    {
        //freopen ("in.txt", "r", stdin);
        cin >> p1 >> p2 >> p3 >> s;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == '-') extend(i);
            else cout << s[i];
        }
        return 0;
    }
    
  • 0
    @ 2016-07-14 11:41:32

    #include <stdio.h>

    int p1,p2,p3;
    char in[1000];
    int i;

    int judge(){
    if(in[i]=='\0')
    return 1;
    if((in[i]=='-'&&(i==0||in[i-1]>=in[i+1]||in[i-1]=='-'))||in[i]!='-'||(in[i]=='-'&&in[i-1]<60&&in[i+1]>60))
    return 2;
    if(in[i]=='-'&&in[i-1]<in[i+1])
    return 3;
    }

    void function(){
    int j,m;
    if(p3==1){
    for(j=in[i-1]+1;j<in[i+1];j++)
    for(m=0;m<p2;m++){
    if(p1==1)
    printf("%c",j);
    if(p1==2){
    if(j>60)
    printf("%c",j-32);
    else
    printf("%c",j);
    }
    if(p1==3)
    printf("*");

    }

    }

    if(p3==2){
    for(j=in[i+1]-1;j>in[i-1];j--)
    for(m=0;m<p2;m++){
    if(p1==1)
    printf("%c",j);
    if(p1==2){
    if(j>60)
    printf("%c",j-32);
    else
    printf("%c",j);
    }
    if(p1==3)
    printf("*");

    }

    }

    }

    int main(){
    scanf("%d%d%d",&p1,&p2,&p3);
    scanf("%s",&in);
    for(i=0;i<1000;i++){
    if(judge()==1)
    break;
    if(judge()==2)
    printf("%c",in[i]);
    if(judge()==3)
    function();
    }

    return 0;
    }

  • 0
    @ 2016-02-15 09:08:45

    Pascal AC
    var s,x:ansistring;
    p1,p2,p3,i,j,k:longint;
    begin
    readln(p1,p2,p3);
    read(s);
    x:='';
    for i:=1 to length(s) do
    if s[i]='-' then begin
    if ((s[i-1]>='a')and(s[i+1]<='z'))or((s[i-1]>='0')and(s[i+1]<='9')) then
    begin
    if ord(s[i+1])<=ord(s[i-1]) then x:=x+s[i];
    if ord(s[i+1])-1>ord(s[i-1]) then begin
    if p1=1 then
    if p3=1 then begin
    for k:=ord(lowercase(s[i-1]))+1 to ord(lowercase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end
    else begin
    for k:=ord(lowercase(s[i+1]))-1 downto ord(lowercase(s[i-1]))+1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end;
    if p1=2 then
    if p3=1 then begin
    for k:=ord(upcase(s[i-1]))+1 to ord(upcase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end
    else begin
    for k:=ord(upcase(s[i+1]))-1 downto ord(upcase(s[i-1]))+1 do
    for j:=1 to p2 do
    x:=x+chr(k);
    end;
    if p1=3 then
    for k:=ord(upcase(s[i-1]))+1 to ord(upcase(s[i+1]))-1 do
    for j:=1 to p2 do
    x:=x+'*';
    end;
    end
    else x:=x+s[i];
    end
    else x:=x+s[i];
    write(x);
    end.

  • 0
    @ 2015-11-02 09:54:21

    var i,j,n,m,k,l,r,x,y,z:longint;
    s:string;
    begin
    readln(x,y,z);
    readln(s);
    s:=' '+s+' ';
    for i:=2 to length(s)-1 do
    begin
    if (i=2)and(s[i]='-') then write(s[i]) else
    if (s[i]='-')and(s[i-1]='-') then write(s[i]) else
    if (i=length(s)-1)and(s[i]='-') then write(s[i]) else
    begin
    l:=ord(s[i-1]);
    r:=ord(s[i+1]);
    if s[i]<>'-' then write(s[i]) else
    begin
    if l>=r then begin write(s[i]); l:=0; r:=0; end else
    if l+1=r then begin l:=0; r:=0; end else
    if (l<60)and(r>60) then begin write(s[i]); l:=0; r:=0; end else
    if (l>60)and(r<60) then begin write(s[i]); l:=0; r:=0; end else
    begin
    if x=3 then
    for j:=1 to (r-l-1)*y do write('*') else begin
    if x=2 then
    if (l>96)and(l<123)and(r>96)and(r<123) then
    begin l:=l-32; r:=r-32; end;
    if z=2 then
    for j:=r-1 downto l+1 do
    for k:=1 to y do write(chr(j))
    else
    for j:=l+1 to r-1 do
    for k:=1 to y do write(chr(j)); end;
    end;
    end;
    end;
    end;
    end.

  • 0
    @ 2015-11-01 22:02:34

    //恶心的细节
    var p1,p2,p3:longint;
    s:string;
    i,j,n1,n2,k,t,min:longint;
    function judge(p,q:char):longint;
    begin
    if (((ord(p)>=48) and (ord(p)<=57) and (ord(q)>=97) and (ord(q)<=122))
    or ((ord(q)>=48) and (ord(q)<=57) and (ord(p)>=97) and (ord(p)<=122))) then exit(-1);
    if (ord(p)+2)<=(ord(q)) then exit(1);
    if (ord(p)+1)=(ord(q)) then exit(0);
    if ((ord(p))>=(ord(q))) then exit(-1);
    end;
    procedure add1(x,y:longint);
    begin
    if p1=1 then
    begin
    for j:=x to y do
    for k:=1 to p2 do
    begin
    write(chr(j));
    end;
    end;
    if p1=2 then
    begin
    for j:=x to y do
    for k:=1 to p2 do
    begin
    write(upcase((chr(j))));
    end;
    end;
    end;
    procedure add2(x,y:longint);
    begin
    if p1=1 then
    begin
    for j:=y downto x do
    for k:=1 to p2 do
    begin
    write(chr(j));
    end;
    end;
    if p1=2 then
    begin
    for j:=y downto x do
    for k:=1 to p2 do
    begin
    write(upcase((chr(j))));
    end;
    end;
    end;
    procedure add(p,q:char);
    begin
    n1:=ord(p)+1;
    n2:=ord(q)-1;
    if p1=3 then
    begin
    for j:=n1 to n2 do
    for k:=1 to p2 do
    begin
    write('*');
    end;
    end;
    if (ord(p)>=ord('0')) and (ord(p)<=ord('9')) and (p1<>3) then
    begin
    if p3=1 then
    begin
    for j:=n1 to n2 do
    for k:=1 to p2 do
    begin
    write(chr(j));
    end;
    end
    else if p3=2 then
    begin
    for j:=n2 downto n1 do
    for k:=1 to p2 do
    begin
    write(chr(j));
    end;
    end;
    end;
    if (ord(p)>=ord('a')) and (ord(p)<=ord('z')) and (p3=1) and (p1<>3) then add1(n1,n2);
    if (ord(p)>=ord('a')) and (ord(p)<=ord('z')) and (p3=2) and (p1<>3) then add2(n1,n2);
    end;
    begin
    readln(p1,p2,p3);
    readln(s);
    min:=1;
    while s[min]='-' do
    begin
    write('-');
    inc(min);
    end;
    for i:=min to length(s)-1 do
    begin
    if s[i]='-' then
    begin
    if judge(s[i-1],s[i+1])=1 then add(s[i-1],s[i+1]);
    if judge(s[i-1],s[i+1])=0 then s[i]:=' ';
    if judge(s[i-1],s[i+1])=-1 then
    begin
    t:=i;
    while s[t]='-' do
    begin
    write('-');
    inc(t);
    end;
    end;
    end
    else write(s[i]);
    end;
    if s[length(s)]='-' then write('-')
    else write(s[length(s)]);
    writeln;
    end.

信息

ID
1379
难度
6
分类
模拟 点击显示
标签
递交数
5989
已通过
1615
通过率
27%
被复制
10
上传者