terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_replace_aux
Aborted
< /code>
Вот код: < /p>
#include
using namespace std;
int main() {
int x, n;
cin >> n >> x;
int z[x * 2];
string st =
"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
st.resize(n);
for (int i = 0; i < x; i += 2) {
cin >> z[i];
}
for (int i = 0; i < x; i += 2) {
int b = z[i] - z[i + 1];
st.replace(z[i], z[i + 1], b, '.');
}
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79780782/what-is-this-error-terminate-called-canafter-throwing-an-instance-of-stdleng[/url]
Я получаю следующую ошибку при запуске кода C ++: < /p> [code]terminate called after throwing an instance of 'std::length_error' what(): basic_string::_M_replace_aux Aborted < /code> Вот код: < /p> #include
using namespace std; int main() { int x, n; cin >> n >> x;
int z[x * 2]; string st = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII" "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"; st.resize(n);
for (int i = 0; i < x; i += 2) { cin >> z[i]; }
for (int i = 0; i < x; i += 2) { int b = z[i] - z[i + 1]; st.replace(z[i], z[i + 1], b, '.'); } cout