zoukankan      html  css  js  c++  java
  • TCL之容器

    • [A] A Breaking Computer

    • 时间限制: 1000 ms 内存限制: 65535 K
    • 问题描述
    • Oh my god.My computer is break.When I writing something,the home and the end always is working.But I also write too quakily,
      even I don't see the screen.OK,when I finish a work ,can you tell me the work become in end?
      We modified the sample output, please check it.
    • 输入
    • This have some cases.
      Every case have a sentence(length< 200000 Include (A->Z a->z 0->9)).Then '[' is the home,']' is the end;
    • 输出
    • Input a sentence.

      Printf the finally sentence.
    • 样例输入
    • 123[4
      123[45]6
      123[45]6[7]8
      
    • 样例输出
    • 4123
      451236
      74512368
    • 代码实现:
    #include<iostream>
    #include<stdio.h>
    #include<vector>
    using namespace std;
    char str[200001];
    vector<char>Q[200001];//定义200001个容器
    int main()
    {
        int i,j,r,flag;
        while(scanf("%s",str)!=EOF)
        {
            r=0;flag=0;
            for(i=0;i<200001;i++)
                Q[i].clear();//容器的清空
            for(i=0;str[i]!='\0';i++)
            {
               if(str[i]=='[')
               {
                  r++;
                  flag=r;
               }
               else if(str[i]==']')
                  flag=0;
               else
               {
                   Q[flag].push_back(str[i]);//进入容器
               }
            }
            for(i=r;i>=0;i--)
            {
                for(j=0;j<Q[i].size();j++)
                    printf("%c",Q[i][j]);
            }
            printf("\n");
        }
        return 0;
    }
    
  • 相关阅读:
    获取滚动条卷入高度以及获取内联和外联的方法
    async
    使一个div元素上下左右居中
    .NetCore/ .NetFramework 机制
    Asp.netCore 是用的Socket 吗?
    Asp.netCore 的Startup 不继承接口
    月球
    JWT
    虚数的作用
    C# mailKit 发邮件 简单代码
  • 原文地址:https://www.cnblogs.com/jiangjing/p/2964490.html
Copyright © 2011-2022 走看看