Advertisement
juneba

Untitled

Jul 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stack>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. int qtd;
  9.  
  10. string linha;
  11. int diamantes =0;
  12. cin >> qtd;
  13.  
  14.  
  15.  
  16. for (int i= 0; i< qtd;i++)
  17. {
  18. diamantes = 0;
  19. cin >> linha;
  20. stack<int> myStack;
  21. for ( int j = 0 ; j < linha.size() ; j++ )
  22. {
  23. if (linha[j] == '<' )
  24. {
  25. myStack.push('<');
  26. }
  27. else
  28. {
  29. if (linha[j] == '>' && !myStack.empty() )
  30. {
  31. diamantes++;
  32. myStack.pop();
  33.  
  34. }
  35. }
  36.  
  37. }
  38. printf("%d\n",diamantes);
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement