自提
2024-12-01 14:37:50
发布于:江苏
0阅读
0回复
0点赞
#include <iostream>
using namespace std;
int stack[100];
int top;
void push(int x)
{
top++;
stack[top] = x;
}
void pop()
{
top--;
}
int getTop()
{
return stack[top];
}
bool empty()
{
if (top == 0)
return true;
return false;
}
int size()
{
return top;
}
string s;
int main()
{
cin >> s;
for (int i = 0; s[i] != '@'; i++)
{
if (s[i] == '(')
push(1);
else if (s[i] == ')')
{
if (empty())
{
cout << "NO";
return 0;
}
else
pop();
}
}
if (empty())
cout << "YES";
else
cout << "NO";
return 0;
}
这里空空如也
有帮助,赞一个