split 2d array into chunks in c++
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("\n");
}
printf("\n\n");
}
return 0;
}
Also in C++:
- Title
- create copy constructor c++
- Category
- C++
- Title
- container class in c++
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- calling by reference and pointers c++
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- coronavirus
- Category
- C++
- Title
- primos menores que
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++
- Title
- c++ scanf
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- pop from between string c++
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- clear console c++
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- string to number in c++
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- building native binary with il2cpp unity
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- power in c++
- Category
- C++
- Title
- c++ program for addition of two numbers using functions
- Category
- C++
- Title
- stringstream in c++
- Category
- C++
- Title
- registering a new QML type
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- c++ replace n substrings
- Category
- C++
- Title
- is x prime?
- Category
- C++
- Title
- map.erase in c++
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- c++ max of array
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- declare vectors c++
- Category
- C++
- Title
- c++ template function
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- insertion c++
- Category
- C++
- Title
- double to string c++
- Category
- C++
- Title
- std string find character c++
- Category
- C++
- Title
- c++ compare char
- Category
- C++
- Title
- getline not working c++
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- convert char to string - c++
- Category
- C++
- Title
- c++ while true loop
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- fmod c++
- Category
- C++
- Title
- how to get the largest number in a c++ array
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- never gonna give you up
- Category
- C++
- Title
- c++ parse int
- Category
- C++
- Title
- gta san andreas
- Category
- C++
- Title
- char vector to string c++
- Category
- C++
- Title
- c++ get type name of object
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- new in c++
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- how to swap string characters in c++
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- memset c++
- Category
- C++
- Title
- how to use assrt c++
- Category
- C++
- Title
- assegnare valori in c++
- Category
- C++
- Title
- vector pop back
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- c++ unittest in ros
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- c++ main function
- Category
- C++
- Title
- screen record ios simulator
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- elseif c++
- Category
- C++
- Title
- c++ reading string
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- C++ If
- Category
- C++
- Title
- how to get last element of set in c++
- Category
- C++
- Title
- cout value c++
- Category
- C++
- Title
- how to read a comma delimited file into an array c++
- Category
- C++
- Title
- list conda environments
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- what is difffrence between s.length() and s.size()
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- appending a double to a string c++
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- char size length c++
- Category
- C++
- Title
- print matrix c++
- Category
- C++
- Title
- COunt the number of continous subsequences such that the sum is between
- Category
- C++
- Title
- how to use winmain function
- Category
- C++
- Title
- how to find length of string in c++
- Category
- C++
- Title
- how to make sure the user inputs a int and not anything else c++
- Category
- C++