zoukankan      html  css  js  c++  java
  • vijos 1379 字符串的展开

    23333333333333333

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define maxn 1005000
    char s[maxn],t[maxn],p[maxn];
    int p1,p2,p3,top=-1,l;
    void work(int x)
    {
        int l=s[x-1],r=s[x+1],cnt=0;
        if ((s[x-1]<='9') && (s[x+1]>'9')) {t[++top]='-';return;}
        if ((s[x-1]=='-') || (s[x+1]=='-')) {t[++top]='-';return;}
        for (int i=l+1;i<=r-1;i++)
        {
            for (int j=1;j<=p2;j++)
            {
                if (p1==3)
                {
                    p[++cnt]='*';
                    continue;
                }
                if ((s[x-1]>='0') && (s[x-1]<='9'))
                    p[++cnt]=i;
                else
                {
                    if (p1==1) p[++cnt]=i;
                    else if (p1==2) p[++cnt]=i-32;
                }
            }
        }
        if (p3==1)
        {
            for (int i=1;i<=cnt;i++)
                t[++top]=p[i];
        }
        else
        {
            for (int i=1;i<=cnt;i++)
                t[++top]=p[cnt-i+1];
        }
    }
    int main()
    {
        scanf("%d%d%d",&p1,&p2,&p3);
        scanf("%s",s);
        l=strlen(s);
        for (int i=0;i<l;i++)
        {
            if (s[i]!='-')
                t[++top]=s[i];
            else
            {
                if (i==0) {t[++top]='-';continue;}
                if (i==l-1) {t[++top]='-';continue;}
                if (s[i-1]==s[i+1]) t[++top]=s[i];
                else if (s[i-1]>s[i+1]) t[++top]=s[i];
                else work(i);
            }
        }
        printf("%s",t);
        return 0;
    }
  • 相关阅读:
    数组塌陷现象
    深浅拷贝的区别
    冒泡排序,选择排序的应用
    JavaScript双重循环的嵌套
    Css Grid网格布局
    css3动画详细介绍
    Python tkinter Label Widget relief upload image
    XXXFD
    XXX1
    Python爬取一个简单网页的HTML代码
  • 原文地址:https://www.cnblogs.com/ziliuziliu/p/5860409.html
Copyright © 2011-2022 走看看