zoukankan      html  css  js  c++  java
  • [HDOJ3528]The Simple Programming Language

    水题~

    View Code
    #include <cstdio>
    #include
    <cstring>

    using namespace std;

    const int MAXW = 1024;
    const int MAXL = 1024000;

    int nw;
    bool ok;
    char input[MAXL];
    char word[MAXW][MAXL];

    void work(int start,int end)
    {
    if (start > end) return;

    if (start == end && word[start][0] == 'w')
    {
    int f = strchr(word[start],'(') - word[start];
    int e = strchr(word[start],')') - word[start];
    for (int i = f + 2;i < e - 1;i++)
    {
    ok
    = true;
    printf(
    "%c",word[start][i]);
    }
    return;
    }

    int cntif = 0;
    int idx = -1;

    for (int i = start + 1;i <= end;i++)
    if (word[i][0] == 'i') cntif++;
    else if (word[i][0] == 'e')
    {
    if (cntif == 0)
    {
    idx
    = i;
    break;
    }
    cntif
    --;
    }

    if (word[start][3] == '1')
    {
    if (idx == -1) work(start + 1,end);
    else work(start + 1,idx - 1);
    }
    else
    if (idx != -1)
    work(idx
    + 1,end);
    }

    int main()
    {
    int idx;
    while (gets(input))
    {
    nw
    = 0;
    for(idx = 0;input[idx] && input[idx] == ' ';idx++) ;
    for (int i = idx;input[i];i++)
    if (i == 0 || (input[i-1] == ' ' && input[i] != ' '))
    sscanf(input
    + i,"%s",word[nw++]);
    while (gets(input) && strlen(input) != 0)
    {
    for(idx = 0;input[idx] && input[idx] == ' ';idx++) ;
    for (int i = idx;input[i];i++)
    if (i == 0 || (input[i-1] == ' ' && input[i] != ' '))
    sscanf(input
    + i,"%s",word[nw++]);
    }

    ok
    = false;
    work(
    0,nw - 1);
    if(ok) printf("\n");
    }
    return 0;
    }
  • 相关阅读:
    问题解决(2)
    问题解决(1)
    ubuntu16.04spyder闪退
    ubuntu16.04安装caffe
    python做批量剪切、旋转等小程序
    html中如何使得改变背景的透明度时,背景上的文字透明度不被改变
    css下拉菜单制作
    float浮动
    css盒子模型
    css选择器,背景样式,文本属性
  • 原文地址:https://www.cnblogs.com/debugcool/p/HDOJ3528.html
Copyright © 2011-2022 走看看