All Questions
Tagged with arrays multidimensional-array
19,335 questions
1
vote
2
answers
64
views
The passing of 2-dimensional arrays to functions in C by only stating the size of the second dimension
When passing a 2-dimensional array to a function in C, I normally just pass it by using a single pointer.
Example : void process_array(int* arr, int rows, int cols)
I see 2-dimensional arrays also ...
3
votes
2
answers
107
views
storing all c stuct arrays in only one single memory segment obtained with malloc/calloc
Suppose I have a database in memory that I want to modify.
Let's say the tables are phone information and items.
The phone information consists of a name up to 99 characters and a character code.
The ...
0
votes
0
answers
44
views
Find the page in a 3D matrix that is closest to a given matrix
One can easily concatenate (stack up) four arrays by using:
B = cat(3, A, A, A, A); % here A is 2-dimensional M x N matrix and B is 3-dimensional M x N x 4 stack
How is it possible to concatenate (...
-3
votes
1
answer
43
views
How to make percent chance that there will be a * in a 2D array decrease
My result
I need to make the number of stars decrease with each line, but I have no idea how.
import random
import numpy as np
import sys
size = int(sys.argv[1])
mat = np.full((size, size), '\x1b[35m....
4
votes
3
answers
157
views
How memory address for pointer to arrays is same as an element in 2D array?
Consider the following code:
#include <stdio.h>
int main()
{
int **s = (int**)malloc(3 * sizeof(int*));
for (int i = 0; i < 3; i++)
{
printf("%d\n", s+i);
}
...
1
vote
1
answer
35
views
Copy first level keys of a 2d array as a new column of each row
Assuming a 2d array as input, how can each first level key be copied as a new element in its second level row?
Sample input:
$members = [
'myname' => ['userid' => 52, 'age' => 46],
'...
1
vote
2
answers
85
views
Why does this multidimension array output as list?
A list
$tags = 'a','b','c','d','e'
the process
$array = New-Object 'object[,]' 3,5
$array[0,0] = $tags[0]
$array[0,1] = $tags[1]
$array[0,2] = $tags[2]
$array[0,3] = $tags[3]
$...
3
votes
1
answer
92
views
Why should native sorting functions be called by array_walk() with explicit sorting function parameters?
I ran a few tests on 2d arrays and found that in some contexts, native sorting functions can give unexpected results when array keys are 2, 5, 10, or 13.
$expected = range(0, 11);
$array = array_fill(...
0
votes
3
answers
111
views
Group values of a flat array into sets of consecutive strings with the same leading characters
I have a dynamic array, each group of lines start with a specific code "S10.G00.00", "S10.G00.01", "S10.G00.02" ...
The array may be like this:
array:20 [▼
0 => &...
1
vote
1
answer
71
views
How to check non-constant array
when I get my data series with foreach, I get the result in the structure below
in the structure
[N]==1 match result 1 win [N]==2 match result ends in a draw [N]==3 match result away win [O] parts are ...
-1
votes
2
answers
73
views
2d array - group by first item and calculate average of corresponding number
I have a 2d array which contains a list of series with title, rating, and time spent watching. For example:
let seriesList = [["Squid Game", 3.5, "4 days"], ["Squid Game",...
1
vote
1
answer
44
views
Questionable output while iterating over an array of arrays
I'm building an array of arrays in Powershell with the goal of iterating over that array and outputting strings from each member element. However in doing so, I'm getting fragments that aren't making ...
-2
votes
4
answers
191
views
How to iterate multidimensional array data and sum some values to return a grouped array
What's the simplest way and uses less computing power to check if a multidimensional array has some equal values in the sub keys and, if is in this way, make the sum of that?
Look at the input. It's ...
0
votes
2
answers
87
views
Get x or y distance between 2 items in a 2D array[,] of any type not knowing the index of either items and edit items in between [closed]
For learning purposes I'm asking "any type" but I actually got a byte[,] type array I'm working on right now, it's called byteTable and its content looks like this:
00 01 E1 03 04 05
...
0
votes
2
answers
107
views
transform/pivot array of objects based on values of a key and reconvert it back to original
I want be able to convert below array or objects with uniform keys, but have it pivoted or transformed into array of objects, but with as many objects as there are properties in an object, with each ...