Witam, mam problem z takim kodem:
#include <iostream>
#include <string>
#include <string>
#include <stdlib.h>
using namespace std;
long long xx;
int n, k;
string x,z;
int main ()
{
cin >> n >> x;
for (int i=0; i < n; i++)
{
z=x.erase (i-1, 1);
xx = atol(z.c_str());
if (xx % 11 == 0)
{
k = i-1;
}
}
cout << k;
return 0;
}
Błąd wyskakuje taki:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::erase: __pos (which is 18446744073709551615) > this->size() (which is 3)
Pomoże ktoś?