HDU 4782 Beautiful Soup 模拟

【思路】

以前遇到这种题,老是想用dfs来写,现在终于知道用栈模拟更方便了 =  =。模拟题,没什么好说的,读懂题意剩下的就是码力的问题了。

//#pragma comment(linker, "/STACK:102400000,102400000")
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define MP(x,y) make_pair((x),(y))
#define PB(x) push_back(x)
typedef __int64 LL;
//typedef unsigned __int64 ULL;
/* ****************** */
const int INF = 100011122;
const double INFF = 1e100;
const double eps = 1e-8;
const int mod = 1000000009;
const int NN = 110;
const int MM = 5000010;
/* ****************** */

void FF_kong(int x)
{
    while(x)
    {
        printf(" ");
        x--;
    }
}

int main()
{
    char c;
    int cas, ee = 0;
    int tail = 0;
    string ss;
    bool tag = true;
    bool need = true;
    bool first;
    scanf("%d",&cas);
    while(1)
    {
        if(tag)
        {
            while(need && (c = getchar()) )
            {
                if(c=='<')
                    break;
            }
            ss = "";
            while( (c = getchar()) )
            {
                if(c=='>')
                    break;
                ss += c;
            }

            if(ss=="html")
            {
                printf("Case #%d:\n",++ee);
            }

            if(ss[ss.size()-1]=='/')
            {
                FF_kong(tail);
                cout<<"<"<"<"<"<


你可能感兴趣的:(数学和杂题)