98862024-03-15 07:17:15BakosCsongorZárójel cserecpp17Compilation error
/*
4
)()(
*/
#include <bits/stdc++.h>

using namespace std;

int N;
vector <char> zarojel;
vector <int> sorszam;
int megoldasok;
vector <vector<int>> meg;

void megold()
{
    for(int i = 0; i < zarojel.size(); i++)
    {
        vector <int> x;
        for(int j = 0; j < zarojel.size(); j++)
        {
            x.push_back()

        }
    }
}

bool compare(vector <int> x, vector <int> y)
{
    return x.size() < y.size();
}

void simplify()
{
    for(int j = 1; j < zarojel.size(); j++)
    {
        if(zarojel.at(j-1) == '(' and zarojel.at(j) == ')')
        {
            zarojel.erase(zarojel.begin()+j-1,zarojel.begin()+j+1);
            sorszam.erase(sorszam.begin()+j-1,sorszam.begin()+j+1);
            j-=2;
        }
    }
}

int main()
{
    //ifstream cin("input0.txt");
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        char c;
        cin >> c;
        zarojel.push_back(c);
        sorszam.push_back(i);

    }
    simplify();
        for(auto element : zarojel)
        {
            cout << element << " ";
        }
        cout << endl;
        for(auto element : sorszam)
        {
            cout << element << " ";
        }
        cout << endl;
    return 0;
}
Compilation error
exit status 1
main.cpp: In function 'void megold()':
main.cpp:22:24: error: no matching function for call to 'std::vector<int>::push_back()'
   22 |             x.push_back()
      |             ~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from main.cpp:5:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::p...