-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1068.cpp
More file actions
35 lines (29 loc) · 802 Bytes
/
1068.cpp
File metadata and controls
35 lines (29 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <stack>
using namespace std;
int main(){
string entrada;
while(cin >> entrada){
stack<char> parenteses;
bool temParentese = false;
for(int i=0; i<entrada.size(); i++){
if(entrada[i] == '('){
temParentese = true;
parenteses.push(entrada[i]);
}
else if (entrada[i] == ')'){
temParentese = true;
if(parenteses.empty()){
parenteses.push('x');
break;
}
parenteses.pop();
}
}
if(!temParentese || !parenteses.empty()){
cout << "incorrect" << endl;
} else {
cout << "correct" << endl;
}
}
}