Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stack>
- using namespace std;
- int main ()
- {
- int qtd;
- string linha;
- int diamantes =0;
- cin >> qtd;
- for (int i= 0; i< qtd;i++)
- {
- diamantes = 0;
- cin >> linha;
- stack<int> myStack;
- for ( int j = 0 ; j < linha.size() ; j++ )
- {
- if (linha[j] == '<' )
- {
- myStack.push('<');
- }
- else
- {
- if (linha[j] == '>' && !myStack.empty() )
- {
- diamantes++;
- myStack.pop();
- }
- }
- }
- printf("%d\n",diamantes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement