注:這里只是我的代碼出現這種情況及對應的解決辦法,你的代碼不一定出現和我一樣的情況。左移這篇隨筆僅供參考。
運行程序出現如下結果:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Process returned 3 (0x3) execution time : 5.837 s
Press any key to continue.
然后發現是 for 循環里面的,本應寫成
for (int j = 1; j <= 3; j ++)
的地方,寫成了
for (int j = 1; j <= 3; j --)
改過來就好了。