Search
 
SCRIPT & CODE EXAMPLE
 

CPP

split 2d array into chunks in c++

int main(int agrc, char *argv[])
{
    const size_t w = 8;
    const size_t h = 3;
    const size_t c = 2;

    int mat[h][w] = {
        { 1, 2, 3, 4, 5, 6, 7, 8 },
        { 1, 2, 3, 4, 5, 6, 7, 8 },
        { 1, 2, 3, 4, 5, 6, 7, 8 }
    };

    int chunks[w / c][h][c];

    split(h, w, mat, c, chunks);

    for (int i = 0; i < w / c; i++) {
        for (int j = 0; j < h; j++) {
            for (int k = 0; k < c; k++) {
                printf("%3d ", chunks[i][j][k]);
            }
            printf("
");
        }
        printf("

");
    }

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: convert char to string c++ 
Cpp :: fishes code in assignment expert 
Cpp :: c++ schleife abbrechen 
Cpp :: c++ enter name and surname one string 
Cpp :: max of 3 numbers in c++ 
Cpp :: c++ trim string 
Cpp :: C++ Single Line Comments 
Cpp :: C++ (.NET CLI) 
Cpp :: max in c++ with three elements 
Cpp :: the statement vector vector int matrix(100 vector int (50 100) ) declares 
Cpp :: std remove example 
Cpp :: c++ Unable to get CMake Tutorial example to compile 
Cpp :: how to change the default camera speed values opengl 
Cpp :: pros millis() 
Cpp :: how to merge string array in C++ 
Cpp :: warning in range-based for loop in C++. How to resolve it in vscode? 
Cpp :: No Index Out of Bound Checking in C++ 
Cpp :: return value from a thread 
Cpp :: c++ how to iterate through 2d array in c++ 
Cpp :: number triangle c++ 
Cpp :: how to complie c++ to spesific name using terminal 
Cpp :: C++: Methods of code shortening in competitive programming 
Cpp :: backward chaining python 
Cpp :: check if string in vector c++ 
Cpp :: nested loop c++ program example 
Cpp :: how to check code execution time in visual studio c++ 
Cpp :: http://dcnet.ddns.ma/Connecter_Tuteur 
Cpp :: what is c++ function 
Cpp :: C++ area & circumference of a circle 
Cpp :: Fibonacci Series Program. in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =