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;
    }
    
  • 相关阅读:
    layui多选框
    js获取html5 audio 音频时长方法
    危害程序员职业生涯的三大观念
    选择器
    C++ STL partial_sort
    C++ STL sort
    C++ STL 排列 next_permutation prev_permutation
    C++ STL 逆转旋转 reverse reverse_copy rotate
    C++ unique
    C++ remove remove_if erase
  • 原文地址:https://www.cnblogs.com/jiangjing/p/2964490.html
Copyright © 2011-2022 走看看