TOPIC

Compilation Error

Brunno Monte asked 1 year ago

Tá dando compilation error e não consigo saber qual o problema.

#include <iostream>
#include <string>
#include <stack>

int main()
{
    int max{0}, cont{0};
    std::stack<char> pilha;
    std::string line;

    std::cin >> max;
    std::cin.ignore();

    for (auto i{0}; i < max; i++)
    {
        std::getline(std::cin, line);
        for (auto &c : line)
        {
            if (c == '<')
                pilha.push(c);

            if (c == '>')
            {
                if (!pilha.empty())
                {
                    pilha.pop();
                    cont++;
                }
            }
        }
        std::cout << cont << std::endl;
        cont = 0;
    }

    return 0;
}

Remember not post solutions. Your post may be reviewed by our moderators.