Какова эта ошибка «завершить завершение после того, как выбросила экземпляр« std :: length_error »что (): basic_string :C++

Программы на C++. Форум разработчиков
Anonymous
Какова эта ошибка «завершить завершение после того, как выбросила экземпляр« std :: length_error »что (): basic_string :

Сообщение Anonymous »

Я получаю следующую ошибку при запуске кода C ++: < /p>

Код: Выделить всё

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-after-throwing-an-instance-of-stdlength[/url]

Вернуться в «C++»