c ++ 3d数组

use*_*061 0 c++ arrays 3d

我正在尝试运行一个3d数组,但是当我运行它时,代码只会在Windows中崩溃,这是我的代码;

#include <iostream>

using namespace std;

int main(){

    int myArray[10][10][10];

    for (int i = 0; i <= 9; ++i){
        for (int t = 0; t <=9; ++t){            
            for (int x = 0; x <= 9; ++t){

                myArray[i][t][x] = i+t+x; 

            }

        }

     }


    for (int i = 0; i <= 9; ++i){
        for (int t = 0; t <=9; ++t){
            for (int x = 0; x <= 9; ++t){

                cout << myArray[i][t][x] << endl;

            }

        }

    }

    system("pause");

}
Run Code Online (Sandbox Code Playgroud)

有人可以给我一个快速解决/解释

Dav*_*man 14

你两次有线

for (int x = 0; x <= 9; ++t){
Run Code Online (Sandbox Code Playgroud)

当你的意思

for (int x = 0; x <= 9; ++x){
Run Code Online (Sandbox Code Playgroud)

经典的复制粘贴错误.

顺便说一句,如果你在调试器中运行它并查看变量的值,很容易看出发生了什么.