请问我的代码为何报runtime error?该如何修改?
题目:
https://vjudge.net/contest/518654/problemPrint/D
我的代码(c++):
#include <iostream>
#include <stack>
#include <cstring>
#include <cstdio>
using namespace std;
char c[100000]={0};
stack <char> s;
int main()
{
//char c[30];
int n=0;
//stack <char> s;
scanf("%s",c);
n=strlen(c);
if (c[0]=='+')
{
s.push('+');
}
else if (c[0]=='-')
{
s.push('-');
}
for (int i=1;i<n;++i)
{
if (c[i]==s.top())
{
s.pop();
}
else
{
s.push(c[i]);
}
}
if (s.empty()==1)
{
printf("Yes");
}
else
{
printf("No");
}
return 0;
}
出错提示: