三维数组的实现

版权声明:未经博主允许请勿转载 https://blog.csdn.net/hlz_12345/article/details/83549651
#include <iostream>
using namespace std;
struct _2darray
{
	int _array[3][3];
	void show();
};
int main()
{
	_2darray _3darray[3];
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				_3darray[i]._array[j][k] = k;   //对三维数组赋值

	for (int i = 0; i < 3; i++)
		_3darray[i].show();   //输出三维数组
	system("pause");
    return 0;  
}

void _2darray::show()
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
			cout << _array[i][j] << " ";
		cout << endl;
	}
	cout << endl;
}

猜你喜欢

转载自blog.csdn.net/hlz_12345/article/details/83549651