-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1069.cpp
More file actions
34 lines (28 loc) · 659 Bytes
/
1069.cpp
File metadata and controls
34 lines (28 loc) · 659 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
#include <iostream>
#include <stack>
using namespace std;
int main() {
int n;
cin >> n;
string expressao[n];
char elemento;
for(int i=0; i<n; i++) {
cin >> expressao[i];
int cont = 0;
stack <char> pilha;
for(int h=0; h<expressao[i].size(); h++) {
elemento = expressao[i][h];
if(elemento == '<') {
pilha.push(elemento);
}
if(elemento == '>') {
if(pilha.size() > 0) {
cont++;
pilha.pop();
}
}
}
cout << cont << endl;
}
return 0;
}