⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zoj1925.cpp

📁 最近在acm.zju.edu.cn上通过的题目的代码
💻 CPP
字号:
/*
 * =====================================================================================
 *
 *       Filename:  tju2277.cpp
 *
 *    Description:  Pasting Strings
 *
 *        Version:  1.0
 *        Created:  2008年09月09日 19时51分29秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Coldwings Alpc42 (D.R.), dodele@gmail.com
 *        Company:  NUDT
 *
 * =====================================================================================
 */

#include<iostream>
#include<string>
#include<vector>

using namespace std;

int s,t;
char st[100000];

bool init() {
    scanf("%d %d",&s,&t);
    if (s==-1 && t==-1)
        return false;
    getchar();
    gets(st);
    return true;
}

void calc() {
    vector<string> tag;
    tag.clear();
    for(int i=0;i<t || !tag.empty();i++)
        if (st[i]=='<' && st[i+1]!='/') {
            string nowlv="";
            while (st[++i]!='>')
                nowlv+=st[i];
            tag.push_back(nowlv);
            printf("<%s>",nowlv.c_str());
        } else if (st[i]=='>' && st[i+1]=='/') {
            while (st[++i]!='>') ;
            printf("</%s>",tag[tag.size()-1].c_str());
            tag.pop_back();
        } else if (i>=s && i<t)
            putchar(st[i]);
    putchar('\n');
}

int main() {
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    while (init()) 
        calc();
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -