已经打上注释,dalao们看看为啥会RE.
查看原帖
已经打上注释,dalao们看看为啥会RE.
105820
阿尔托莉雅丶楼主2020/11/5 10:18
当数据是[2[2[2[2[2[2[2[2[2[2YEAH]]]]]]]]]]时 本地有结果 但是洛谷ide却时RE```


include <stdio.h>
include <string.h>
int top = -1; char stack[20009], ch; void s(int l, int);

int main (void) { s(0, 0);

printf("%s", stack);

return 0;
}

void s(int l,int n)//n为压缩次数,l为最近一次[的下标; { while((ch = getchar()) != '\n') { if(ch == ']') { char tem[20000]; int i; stack[top + 1] = '\0'; //结束字符 strcpy(tem, stack + l + 1);//把[之后的字符提取出来 stack[l] = '\0';
for(i = 0;i < n; i++) { strcat(stack, tem);//加在去掉 [ 的stack之后

        }
        top = strlen(stack) - 1; //更新栈顶 
        return;
    }
    else if(ch == '[')
    {
        int t;
        stack[++top] = ch;
        scanf("%d", &t); //t记录压缩次数 
        s(top, t);
    }
    else
    {
        stack[++top] = ch;
    }
}
}
2020/11/5 10:18
加载中...