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;
}

 

转载于:https://www.cnblogs.com/jiangjing/archive/2013/03/17/2964490.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值