TOPIC
Por que está dando Runtime Error?
Marcelo Lupatini asked 2 years ago
Eu não entendo o porquê de estar dando Runtime Error. Alguém poderia me ajudar a descobrir o motivo? Aqui vai o código:
#include <iostream>
#include <stack>
using namespace std;
int main()
{
int n;
cin >> n;
string s;
stack<char> linha, aux;
for (int i=0; i<n; i++){
cin >> s;
for (auto c: s)
linha.push(c);
int cont=0;
bool menor=false, maior=false;
for (int i=0; i<=linha.size()+aux.size(); i++){
aux.push(linha.top());
linha.pop();
if (menor && !maior && aux.top() == '>')
menor = false;
if (aux.top() == '>')
maior = true;
else if (aux.top() == '<')
menor = true;
if (maior && menor){
while (aux.top() != '>')
aux.pop();
aux.pop();
while (!aux.empty()){
linha.push(aux.top());
aux.pop();
}
menor=false, maior=false;
i = 0;
cont++;
}
}
cout << cont << endl;
while (!linha.empty())
linha.pop();
}
return 0;
}
This topic has not been answered yet. Be the first!