⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e05-03.cpp

📁 游戏开发数据结构Data Structures for Game Programmers
💻 CPP
字号:
// =======================================================
//  Chapter 5, Example 3
//  Demonstrating the Array3D Class
// =======================================================
#include "Array3D.h"



void main()
{
    // declare the arrays.
    Array3D<int> iarray( 2, 5, 3 );
    Array3D<float> farray( 3, 4, 5 );

    int i, x, y, z;
    float f;

    // set a few cells
    iarray.Get( 1, 4, 0) = 10;
    farray.Get( 3, 2, 3 ) = 0.5f;
    
    // retrieve the cells that we just set.
    i = iarray.Get( 1, 4, 0 );
    f = farray.Get( 3, 2, 3 );

    // get the size of each array.
    i = iarray.Size();
    i = farray.Size();

    // fill the integer array with consecutive numbers
    for( z = 0; z < 3; z++ )
    {
        for( y = 0; y < 5; y++ )
        {
            for( x = 0; x < 2; x++ )
            {
                iarray.Get( x, y, z ) = (z * 2 * 5) + (y * 2) + (x);
            }
        }
    }

    // resize the array to make it larger:
    iarray.Resize( 3, 6, 4 );

    // resize the array to make is smaller:
    iarray.Resize( 2, 2, 2 );

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -