풀스택 개발자
2020. 8. 25. 17:07
#include<iostream>
#include<string.h>
#include<stack>
using namespace std;
int main() {
stack<char> s;
char a[50];
int check = 1;
cin.getline(a, 50, '\n');
for (int i = 0; i < strlen(a); i++)
{
if (a[i] == '(')
{
s.push(a[i]);
}
else
{
if (s.empty())
{
check = 0;
break;
}
else
{
s.pop();
}
}
}
if (s.empty()&&check==1)
{
cout << "YES";
}
else
{
cout << "NO";
}
}